X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=lib%2Fsocket.c;h=6bf3cfff23d2d65dfe6120201c33b211de114c9e;hb=63f36a0923e8aef6ef3f91cd30fba8ddc9f9509a;hp=c518603c5ef7896378bbd72e67ace1dda42dcfa4;hpb=d46c3d622ba5e7cf7318642e674d68cdeb0bd7e5;p=deb_libnfs.git diff --git a/lib/socket.c b/lib/socket.c index c518603..6bf3cff 100644 --- a/lib/socket.c +++ b/lib/socket.c @@ -174,10 +174,14 @@ static int rpc_write_to_socket(struct rpc_context *rpc) pdu->written += count; if (pdu->written == total) { + unsigned int hash; + rpc->outqueue.head = pdu->next; if (pdu->next == NULL) rpc->outqueue.tail = NULL; - rpc_enqueue(&rpc->waitpdu, pdu); + + hash = rpc_hash_xid(pdu->xid); + rpc_enqueue(&rpc->waitpdu[hash], pdu); } } return 0; @@ -607,6 +611,7 @@ static void reconnect_cb(struct rpc_context *rpc, int status, void *data _U_, vo static int rpc_reconnect_requeue(struct rpc_context *rpc) { struct rpc_pdu *pdu; + unsigned int i; assert(rpc->magic == RPC_CONTEXT_MAGIC); @@ -620,12 +625,16 @@ static int rpc_reconnect_requeue(struct rpc_context *rpc) /* socket is closed so we will not get any replies to any commands * in flight. Move them all over from the waitpdu queue back to the out queue */ - for (pdu=rpc->waitpdu.head; pdu; pdu=pdu->next) { - rpc_return_to_queue(&rpc->outqueue, pdu); - /* we have to re-send the whole pdu again */ - pdu->written = 0; + for (i = 0; i < HASHES; i++) { + struct rpc_queue *q = &rpc->waitpdu[i]; + + for (pdu=q->head; pdu; pdu=pdu->next) { + rpc_return_to_queue(&rpc->outqueue, pdu); + /* we have to re-send the whole pdu again */ + pdu->written = 0; + } + rpc_reset_queue(q); } - rpc_reset_queue(&rpc->waitpdu); if (rpc->auto_reconnect != 0) { rpc->connect_cb = reconnect_cb; @@ -734,14 +743,19 @@ int rpc_queue_length(struct rpc_context *rpc) { int i=0; struct rpc_pdu *pdu; + unsigned int n; assert(rpc->magic == RPC_CONTEXT_MAGIC); for(pdu = rpc->outqueue.head; pdu; pdu = pdu->next) { i++; } - for(pdu = rpc->waitpdu.head; pdu; pdu = pdu->next) { - i++; + + for (n = 0; n < HASHES; n++) { + struct rpc_queue *q = &rpc->waitpdu[n]; + + for(pdu = q->head; pdu; pdu = pdu->next) + i++; } return i; }