MySQL Lists are EOL. Please join:

List:Internals« Previous MessageNext Message »
From:Stewart Smith Date:August 16 2005 10:40pm
Subject:bk commit into 5.0 tree (stewart:1.1888) BUG#10950
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of stewart. When stewart 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
  1.1888 05/08/17 08:40:11 stewart@stripped +4 -0
  BUG#10950
  
  make previous patch portable by abstracting to Ndb_check_socket_hup.
  Is in portlib rather than mysys due to the socket parameter being NDB_SOCKET_TYPE

  ndb/src/mgmapi/mgmapi.cpp
    1.50 05/08/17 08:40:03 stewart@stripped +1 -8
    Use the portable (portlib) Ndb_check_socket_hup to check socket status

  ndb/src/common/portlib/win32/NdbTCP.c
    1.3 05/08/17 08:40:03 stewart@stripped +32 -0
    Implement Ndb_check_socket_hup(NDB_SOCKET_TYPE) for win32 using the select() call.
    
    (should work okay - unable to test on win32 due to status of ndb port though)

  ndb/src/common/portlib/NdbTCP.cpp
    1.12 05/08/17 08:40:03 stewart@stripped +15 -0
    Implement Ndb_check_socket_hup for unix like systems using the poll system call.

  ndb/include/portlib/NdbTCP.h
    1.9 05/08/17 08:40:03 stewart@stripped +2 -0
    Add Ndb_check_socket_hup prototype

# 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:	stewart
# Host:	kennedy.(none)
# Root:	/home/stewart/Documents/MySQL/5.0/bug10950

--- 1.2/ndb/src/common/portlib/win32/NdbTCP.c	2004-11-12 07:38:40 +11:00
+++ 1.3/ndb/src/common/portlib/win32/NdbTCP.c	2005-08-17 08:40:03 +10:00
@@ -37,3 +37,35 @@
     return -1;
 }
 
+int Ndb_check_socket_hup(NDB_SOCKET_TYPE sock)
+{
+  fd_set readfds, writefds, errorfds;
+  struct timeval tv= {0,0};
+  int s_err;
+  int s_err_size= sizeof(s_err);
+
+  FD_ZERO(&readfds);
+  FD_ZERO(&writefds);
+  FD_ZERO(&errorfds);
+
+  FD_SET(sock, &readfds);
+  FD_SET(sock, &writefds);
+  FD_SET(sock, &errorfds);
+
+  if(select(1, &readfds, &writefds, &errorfds, &t)==SOCKET_ERROR)
+    return 1;
+
+  if(FD_ISSET(sock,&errorfds))
+    return 1;
+
+  s_err=0;
+  if (getsockopt(sock, SOL_SOCKET, SO_ERROR, (char*) &s_err, &s_err_size) != 0)
+    return(1);
+
+  if (s_err)
+  {                                             /* getsockopt could succeed */
+    return(1);                                 /* but return an error... */
+  }
+
+  return 0;
+}

--- 1.8/ndb/include/portlib/NdbTCP.h	2005-07-15 01:54:32 +10:00
+++ 1.9/ndb/include/portlib/NdbTCP.h	2005-08-17 08:40:03 +10:00
@@ -95,6 +95,8 @@
 int NDB_CLOSE_SOCKET(int fd);
 #endif
 
+int Ndb_check_socket_hup(NDB_SOCKET_TYPE sock);
+
 #ifdef	__cplusplus
 }
 #endif

--- 1.11/ndb/src/common/portlib/NdbTCP.cpp	2005-07-15 01:54:32 +10:00
+++ 1.12/ndb/src/common/portlib/NdbTCP.cpp	2005-08-17 08:40:03 +10:00
@@ -83,3 +83,18 @@
   return -1;
 }
 #endif
+
+int Ndb_check_socket_hup(NDB_SOCKET_TYPE sock)
+{
+  struct pollfd pfd[1];
+  int r;
+
+  pfd[0].fd= sock;
+  pfd[0].events= POLLHUP | POLLIN | POLLOUT | POLLNVAL;
+  pfd[0].revents= 0;
+  r= poll(pfd,1,0);
+  if(pfd[0].revents & (POLLHUP|POLLERR))
+    return 1;
+
+  return 0;
+}

--- 1.49/ndb/src/mgmapi/mgmapi.cpp	2005-07-22 22:18:35 +10:00
+++ 1.50/ndb/src/mgmapi/mgmapi.cpp	2005-08-17 08:40:03 +10:00
@@ -360,19 +360,12 @@
 extern "C"
 int ndb_mgm_is_connected(NdbMgmHandle handle)
 {
-  struct pollfd pfd[1];
-  int r;
-
   if(!handle)
     return 0;
 
   if(handle->connected)
   {
-    pfd[0].fd= handle->socket;
-    pfd[0].events= POLLHUP | POLLIN | POLLOUT | POLLNVAL;
-    pfd[0].revents= 0;
-    r= poll(pfd,1,0);
-    if(pfd[0].revents & POLLHUP)
+    if(Ndb_check_socket_hup(handle->socket))
     {
       handle->connected= 0;
       NDB_CLOSE_SOCKET(handle->socket);
Thread
bk commit into 5.0 tree (stewart:1.1888) BUG#10950Stewart Smith17 Aug