[Commits] Rev 3476: Test commit in file:///H:/bzr/10.0-serg/

Vladislav Vaintroub wlad at montyprogram.com
Mon Nov 5 20:03:03 EET 2012


At file:///H:/bzr/10.0-serg/

------------------------------------------------------------
revno: 3476
revision-id: wlad at montyprogram.com-20121105180252-pp3t81vm2y70t0xz
parent: sergii at pisem.net-20121105114017-is3ogac6l5k8345j
committer: Vladislav Vaintroub <wlad at montyprogram.com>
branch nick: 10.0-serg
timestamp: Mon 2012-11-05 19:02:52 +0100
message:
  Test commit
  
  MDEV-156 Threadpool - add thd_wait_begin/thd_wait_end to the network IO functions
-------------- next part --------------
=== modified file 'include/mysql/service_thd_wait.h'
--- a/include/mysql/service_thd_wait.h	2011-06-30 15:46:53 +0000
+++ b/include/mysql/service_thd_wait.h	2012-11-05 18:02:52 +0000
@@ -74,7 +74,8 @@
   THD_WAIT_BINLOG= 8,
   THD_WAIT_GROUP_COMMIT= 9,
   THD_WAIT_SYNC= 10,
-  THD_WAIT_LAST= 11
+  THD_WAIT_NET= 11,
+  THD_WAIT_LAST= 12
 } thd_wait_type;
 
 extern struct thd_wait_service_st {

=== modified file 'include/violite.h'
--- a/include/violite.h	2012-11-04 20:04:04 +0000
+++ b/include/violite.h	2012-11-05 18:02:52 +0000
@@ -105,7 +105,9 @@
 ssize_t vio_pending(Vio *vio);
 #endif
 /* Set timeout for a network operation. */
-int vio_timeout(Vio *vio, uint which, int timeout_sec);
+extern int vio_timeout(Vio *vio, uint which, int timeout_sec);
+extern void vio_set_wait_callback(void (*before_wait)(void),
+                                void (*after_wait)(void));
 /* Connect to a peer. */
 my_bool vio_socket_connect(Vio *vio, struct sockaddr *addr, socklen_t len,
                            int timeout);

=== modified file 'sql/scheduler.cc'
--- a/sql/scheduler.cc	2012-11-02 09:43:52 +0000
+++ b/sql/scheduler.cc	2012-11-05 18:02:52 +0000
@@ -27,6 +27,7 @@
 #include "mysqld.h"
 #include "sql_class.h"
 #include "sql_callback.h"
+#include <violite.h>
 
 /*
   End connection, in case when we are using 'no-threads'
@@ -62,6 +63,15 @@
 static void scheduler_wait_sync_end(void) {
   thd_wait_end(NULL);
 }
+
+static void scheduler_wait_net_begin(void) {
+   thd_wait_begin(NULL, THD_WAIT_NET);
+}
+
+static void scheduler_wait_net_end(void) {
+   thd_wait_end(NULL);
+}
+
 };
 /**@}*/
 
@@ -77,6 +87,9 @@
                              scheduler_wait_lock_end);
   thr_set_sync_wait_callback(scheduler_wait_sync_begin,
                              scheduler_wait_sync_end);
+
+  vio_set_wait_callback(scheduler_wait_net_begin,
+    scheduler_wait_net_end);
 }
 
 

=== modified file 'vio/viosocket.c'
--- a/vio/viosocket.c	2012-10-12 09:00:01 +0000
+++ b/vio/viosocket.c	2012-11-05 18:02:52 +0000
@@ -37,6 +37,36 @@
 # include <sys/filio.h>
 #endif
 
+/* Net wait callbacks */
+static void (*before_io_wait)(void)= 0;
+static void (*after_io_wait)(void)= 0;
+
+#define START_SOCKET_WAIT(locker, state_ptr, sock, which) \
+do                                           \
+{                                            \
+  MYSQL_START_SOCKET_WAIT(locker, state_ptr, sock, \
+                            which, 0); \
+  if (before_io_wait)  \
+    before_io_wait();  \
+} while(0)
+
+#define END_SOCKET_WAIT(locker) \
+do \
+{ \
+  MYSQL_END_SOCKET_WAIT(locker, 0); \
+  if (after_io_wait)  \
+    after_io_wait(); \
+} while(0)
+
+
+
+void vio_set_wait_callback(void (*before_wait)(void),
+                                void (*after_wait)(void))
+{
+  before_io_wait= before_wait;
+  after_io_wait= after_wait;
+}
+
 int vio_errno(Vio *vio __attribute__((unused)))
 {
   /* These transport types are not Winsock based. */
@@ -903,12 +933,12 @@
   */
   if (timeout != 0 && vio->async_context && vio->async_context->active)
   {
-    MYSQL_START_SOCKET_WAIT(locker, &state, vio->mysql_socket,
+    START_SOCKET_WAIT(locker, &state, vio->mysql_socket,
                             PSI_SOCKET_SELECT, 0);
     ret= my_io_wait_async(vio->async_context, event, timeout);
     if (ret == 0)
       errno= SOCKET_ETIMEDOUT;
-    MYSQL_END_SOCKET_WAIT(locker, 0);
+    END_SOCKET_WAIT(locker);
     DBUG_RETURN(ret);
   }
 
@@ -933,8 +963,7 @@
     break;
   }
 
-  MYSQL_START_SOCKET_WAIT(locker, &state, vio->mysql_socket, PSI_SOCKET_SELECT, 0);
-
+  START_SOCKET_WAIT(locker, &state, vio->mysql_socket, PSI_SOCKET_SELECT);
   /*
     Wait for the I/O event and return early in case of
     error or timeout.
@@ -957,7 +986,7 @@
     break;
   }
 
-  MYSQL_END_SOCKET_WAIT(locker, 0);
+  END_SOCKET_WAIT(locker);
   DBUG_RETURN(ret);
 }
 
@@ -978,12 +1007,12 @@
   */
   if (timeout != 0 && vio->async_context && vio->async_context->active)
   {
-    MYSQL_START_SOCKET_WAIT(locker, &state, vio->mysql_socket,
-                            PSI_SOCKET_SELECT, 0);
+    START_SOCKET_WAIT(locker, &state, vio->mysql_socket,
+                            PSI_SOCKET_SELECT);
     ret= my_io_wait_async(vio->async_context, event, timeout);
     if (ret == 0)
       WSASetLastError(SOCKET_ETIMEDOUT);
-    MYSQL_END_SOCKET_WAIT(locker, 0);
+    END_SOCKET_WAIT(locker);
     DBUG_RETURN(ret);
   }
 
@@ -1014,12 +1043,12 @@
     break;
   }
 
-  MYSQL_START_SOCKET_WAIT(locker, &state, vio->mysql_socket, PSI_SOCKET_SELECT, 0);
+  START_SOCKET_WAIT(locker, &state, vio->mysql_socket, PSI_SOCKET_SELECT);
 
   /* The first argument is ignored on Windows. */
   ret= select(0, &readfds, &writefds, &exceptfds, (timeout >= 0) ? &tm : NULL);
 
-  MYSQL_END_SOCKET_WAIT(locker, 0);
+  END_SOCKET_WAIT(locker);
 
   /* Set error code to indicate a timeout error. */
   if (ret == 0)



More information about the commits mailing list