--------------------- PatchSet 5026 Date: 2002/09/17 21:35:52 Author: rbcollins Branch: fixrange Tag: (none) Log: factor typecast from ConnStateData into a method, and the logic for connIsUsable for clarity Members: src/client_side.c:1.72.2.18->1.72.2.19 Index: squid/src/client_side.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/client_side.c,v retrieving revision 1.72.2.18 retrieving revision 1.72.2.19 diff -u -r1.72.2.18 -r1.72.2.19 --- squid/src/client_side.c 17 Sep 2002 21:12:14 -0000 1.72.2.18 +++ squid/src/client_side.c 17 Sep 2002 21:35:52 -0000 1.72.2.19 @@ -1,6 +1,6 @@ /* - * $Id: client_side.c,v 1.72.2.18 2002/09/17 21:12:14 rbcollins Exp $ + * $Id: client_side.c,v 1.72.2.19 2002/09/17 21:35:52 rbcollins Exp $ * * DEBUG: section 33 Client-side Routines * AUTHOR: Duane Wessels @@ -141,7 +141,8 @@ static void clientLogRequest(clientHttpRequest *); static void httpRequestFreeResources(clientHttpRequest *); static void connEmptyOSReadBuffers(int fd); - +static int connIsUsable(ConnStateData *conn); +static clientSocketContext *connGetCurrentContext(ConnStateData *conn); clientStreamNode * getTail (clientSocketContext *context) @@ -155,7 +156,7 @@ { clientSocketContext **tempContextPointer; assert (conn); - assert(conn->currentobject != NULL); + assert(connGetCurrentContext(conn) != NULL); /* Unlink us from the connection request list */ tempContextPointer = (clientSocketContext **)&conn->currentobject; while (*tempContextPointer) { @@ -398,7 +399,7 @@ { clientSocketContext *context; assert(connState != NULL); - context = connState->currentobject; + context = connGetCurrentContext(connState); while (context) { if (context->http->conn != connState) return 0; @@ -411,9 +412,9 @@ connFreeAllContexts(ConnStateData *connState) { clientSocketContext *context; - while ((context = connState->currentobject) != NULL) { - assert(connState->currentobject != - ((clientSocketContext *) connState->currentobject)->next); + while ((context = connGetCurrentContext(connState)) != NULL) { + assert(connGetCurrentContext(connState) != + connGetCurrentContext(connState)->next); cbdataFree(context); } } @@ -511,6 +512,21 @@ return 0; } +int +connIsUsable(ConnStateData *conn) +{ + if (!conn ||conn->fd == -1) + return 0; + return 1; +} + +clientSocketContext * +connGetCurrentContext(ConnStateData *conn) +{ + assert (conn); + return conn->currentobject; +} + /* * Write a chunk of data to a client socket. If the reply is present, send the reply headers down the wire too, * and clean them up when finished. @@ -535,9 +551,9 @@ assert(node->data != NULL); assert(node->node.next == NULL); context = node->data; - assert(http->conn && http->conn->fd != -1); + assert(connIsUsable(http->conn)); fd = http->conn->fd; - if (http->conn->currentobject != context) { + if (connGetCurrentContext(http->conn) != context) { /* there is another object in progress, defer this one */ debug(33, 2) ("clientSocketRecipient: Deferring %s\n", http->uri); context->flags.deferred = 1; @@ -636,7 +652,7 @@ debug(33, 3) ("clientKeepaliveNextRequest: FD %d\n", conn->fd); conn->defer.until = 0; /* Kick it to read a new request */ cbdataFree(context); - if ((context = conn->currentobject) == NULL) { + if ((context = connGetCurrentContext(conn)) == NULL) { debug(33, 5) ("clientKeepaliveNextRequest: FD %d reading next req\n", conn->fd); fd_note(conn->fd, "Waiting for next request"); @@ -1055,7 +1071,7 @@ conn->in.offset += size; conn->in.buf[conn->in.offset] = '\0'; /* Terminate the string */ } else if (size == 0) { - if (conn->currentobject == NULL && conn->in.offset == 0) { + if (connGetCurrentContext(conn) == NULL && conn->in.offset == 0) { /* no current or pending requests */ debug(33, 4) ("clientReadRequest: FD %d closed\n", fd); comm_close(fd);