From: Date: November 27 2006 11:07pm Subject: bk commit into 5.1 tree (jonas:1.2073) BUG#24011 List-Archive: http://lists.mysql.com/commits/15899 X-Bug: 24011 Message-Id: <20061127220726.24E24625C2E@perch.ndb.mysql.com> Below is the list of changes that have just been committed into a local 5.1 repository of jonas. When jonas does a push these changes will be propagated to the main repository and, within 24 hours after the push, to the public repository. For information on how to access the public repository see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html ChangeSet@stripped, 2006-11-27 23:07:22+01:00, jonas@stripped +2 -0 ndb - bug#24011 mgmapi during high load problem recommit in mysql-5.1-wl2325-5.0 storage/ndb/src/common/util/InputStream.cpp@stripped, 2006-11-27 23:07:21+01:00, jonas@stripped +6 -20 fix problem with half packages storage/ndb/src/common/util/socket_io.cpp@stripped, 2006-11-27 23:07:21+01:00, jonas@stripped +55 -32 fix problem with half packages # This is a BitKeeper patch. What follows are the unified diffs for the # set of deltas contained in the patch. The rest of the patch, the part # that BitKeeper cares about, is below these diffs. # User: jonas # Host: perch.ndb.mysql.com # Root: /home/jonas/src/mysql-5.1-wl2325-5.0 --- 1.5/storage/ndb/src/common/util/InputStream.cpp 2006-11-27 23:07:26 +01:00 +++ 1.6/storage/ndb/src/common/util/InputStream.cpp 2006-11-27 23:07:26 +01:00 @@ -43,28 +43,14 @@ char* SocketInputStream::gets(char * buf, int bufLen) { + buf[0] = 255; assert(bufLen >= 2); - int offset= 0; - if(m_startover) - { - buf[0]= '\0'; - m_startover= false; - } - else - offset= strlen(buf); - - int res = readln_socket(m_socket, m_timeout, buf+offset, bufLen-offset); - - if(res == 0) - { - buf[0]=0; - return buf; - } - - m_startover= true; - + int res = readln_socket(m_socket, m_timeout, buf, bufLen - 1); if(res == -1) return 0; - + if(res == 0 && buf[0] == 255) + { // select return 0 + buf[0] = 0; + } return buf; } --- 1.9/storage/ndb/src/common/util/socket_io.cpp 2006-11-27 23:07:26 +01:00 +++ 1.10/storage/ndb/src/common/util/socket_io.cpp 2006-11-27 23:07:26 +01:00 @@ -53,10 +53,6 @@ if(buflen <= 1) return 0; - int sock_flags= fcntl(socket, F_GETFL); - if(fcntl(socket, F_SETFL, sock_flags | O_NONBLOCK) == -1) - return -1; - fd_set readset; FD_ZERO(&readset); FD_SET(socket, &readset); @@ -71,43 +67,70 @@ } if(selectRes == -1){ - fcntl(socket, F_SETFL, sock_flags); return -1; } - const int t = recv(socket, buf, buflen, MSG_PEEK); - - if(t < 1) + char* ptr = buf; + int len = buflen; + do { - fcntl(socket, F_SETFL, sock_flags); - return -1; - } + int t; + while((t = recv(socket, ptr, len, MSG_PEEK)) == -1 && errno == EINTR); + + if(t < 1) + { + return -1; + } - for(int i=0; i< t;i++) - { - if(buf[i] == '\n'){ - int r= recv(socket, buf, i+1, 0); - buf[i+1]= 0; - if(r < 1) { - fcntl(socket, F_SETFL, sock_flags); - return -1; + + for(int i = 0; i 0 && buf[i-1] == '\r') + { + buf[i-1] = '\n'; + ptr--; + } + ptr[0]= 0; + return ptr - buf; } - - if(i > 0 && buf[i-1] == '\r'){ - buf[i-1] = '\n'; - buf[i]= '\0'; + } + + for (int tmp = t; tmp; ) + { + while ((t = recv(socket, ptr, tmp, 0)) == -1 && errno == EINTR); + if (t < 1) + { + return -1; } - - fcntl(socket, F_SETFL, sock_flags); - return r; + ptr += t; + len -= t; + tmp -= t; } - } - int r= recv(socket, buf, t, 0); - if(r>=0) - buf[r] = 0; - fcntl(socket, F_SETFL, sock_flags); - return r; + FD_ZERO(&readset); + FD_SET(socket, &readset); + timeout.tv_sec = (timeout_millis / 1000); + timeout.tv_usec = (timeout_millis % 1000) * 1000; + const int selectRes = select(socket + 1, &readset, 0, 0, &timeout); + if(selectRes != 1){ + return -1; + } + } while (len > 0); + + return -1; } extern "C"