From 2cd86f11dda8bb377718b0d3e04924ee8f79cb59 Mon Sep 17 00:00:00 2001 From: krishna Date: Mon, 12 Sep 2011 17:41:32 +0530 Subject: nfs: size_t is an unsigned type. Changing it to ssize_t for "writelen" variable. Also propogate error to the calling functions. Change-Id: If8ba73ac57bc235a28c1e1cdc7a5e11947e7a52f BUG: 3526 Reviewed-on: http://review.gluster.com/400 Tested-by: Gluster Build System Reviewed-by: Shehjar Tikoo --- xlators/nfs/lib/src/rpc-socket.c | 4 ++-- xlators/nfs/lib/src/rpcsvc.c | 24 ++++++++++++++---------- 2 files changed, 16 insertions(+), 12 deletions(-) (limited to 'xlators') diff --git a/xlators/nfs/lib/src/rpc-socket.c b/xlators/nfs/lib/src/rpc-socket.c index 01380450ecc..62817be93d8 100644 --- a/xlators/nfs/lib/src/rpc-socket.c +++ b/xlators/nfs/lib/src/rpc-socket.c @@ -228,8 +228,8 @@ nfs_rpcsvc_socket_read (int sockfd, char *readaddr, size_t readsize) ssize_t nfs_rpcsvc_socket_write (int sockfd, char *buffer, size_t size, int *eagain) { - size_t writelen = -1; - ssize_t written = 0; + ssize_t writelen = -1; + ssize_t written = 0; if (!buffer) return -1; diff --git a/xlators/nfs/lib/src/rpcsvc.c b/xlators/nfs/lib/src/rpcsvc.c index 179fd9b4d3c..5798aa66934 100644 --- a/xlators/nfs/lib/src/rpcsvc.c +++ b/xlators/nfs/lib/src/rpcsvc.c @@ -2638,30 +2638,33 @@ tx_remaining: /* If we've broken out of the loop above then we must unblock * the transmission now. */ - nfs_rpcsvc_socket_unblock_tx (conn->sockfd); - if (list_empty (&conn->txbufs)) - conn->eventidx = event_select_on (conn->stage->eventpool, - conn->sockfd, conn->eventidx, - -1, 0); - - return 0; + if (written != -1) { + nfs_rpcsvc_socket_unblock_tx (conn->sockfd); + if (list_empty (&conn->txbufs)) + conn->eventidx = event_select_on (conn->stage->eventpool, + conn->sockfd, conn->eventidx, + -1, 0); + return 0; + } else + return -1; } int nfs_rpcsvc_conn_data_poll_out (rpcsvc_conn_t *conn) { + int ret = -1; if (!conn) return -1; pthread_mutex_lock (&conn->connlock); { - __nfs_rpcsvc_conn_data_poll_out (conn); + ret = __nfs_rpcsvc_conn_data_poll_out (conn); } pthread_mutex_unlock (&conn->connlock); - return 0; + return ret; } @@ -2685,7 +2688,8 @@ nfs_rpcsvc_conn_data_handler (int fd, int idx, void *data, int poll_in, return 0; } - if (poll_in) { + /* don't handle poll_in if we failed when we handled poll_out */ + if ((ret != -1) && poll_in) { ret = 0; ret = nfs_rpcsvc_conn_data_poll_in (conn); } -- cgit