List:Internals« Previous MessageNext Message »
From:sasha Date:October 12 2001 3:37pm
Subject:bk commit into 4.0 tree
View as plain text  
Below is the list of changes that have just been committed into a
4.0 repository of sasha. When sasha does a push, they will be propogated 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://www.mysql.com/doc/I/n/Installing_source_tree.html

ChangeSet@stripped, 2001-10-12 09:37:25-06:00, sasha@stripped
  changed manager to use my_net_*
  fixed bug in master - unregister slaves when they disconnect

  client/mysqlmanagerc.c
    1.6 01/10/12 09:37:24 sasha@stripped +2 -2
    changed default port

  include/mysql.h
    1.36 01/10/12 09:37:24 sasha@stripped +1 -1
    use my_net_*

  libmysql/manager.c
    1.3 01/10/12 09:37:24 sasha@stripped +28 -54
    use my_net_*

  mysql-test/mysql-test-run.sh
    1.113 01/10/12 09:37:24 sasha@stripped +7 -0
    added support for client strace

  sql/sql_parse.cc
    1.178 01/10/12 09:37:24 sasha@stripped +2 -0
    unregister slaves on disconnect

  sql/sql_repl.cc
    1.60 01/10/12 09:37:24 sasha@stripped +19 -6
    unregister slaves on disconnect

  sql/sql_repl.h
    1.13 01/10/12 09:37:24 sasha@stripped +2 -0
    unregister slaves on disconnect

  tools/mysqlmanager.c
    1.20 01/10/12 09:37:24 sasha@stripped +59 -89
    changed to use my_net_*

# 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:	sasha
# Host:	mysql.sashanet.com
# Root:	/home/sasha/src/bk/mysql-4.0

--- 1.35/include/mysql.h	Sun Oct  7 20:00:04 2001
+++ 1.36/include/mysql.h	Fri Oct 12 09:37:24 2001
@@ -238,7 +238,7 @@
   
 typedef struct st_mysql_manager
 {
-  Vio* vio;
+  NET net;
   char *host,*user,*passwd;
   unsigned int port;
   my_bool free_me;

--- 1.112/mysql-test/mysql-test-run.sh	Thu Oct 11 13:54:04 2001
+++ 1.113/mysql-test/mysql-test-run.sh	Fri Oct 12 09:37:24 2001
@@ -234,6 +234,9 @@
       EXTRA_MASTER_MYSQLD_OPT="$EXTRA_MASTER_MYSQLD_OPT $1"
       EXTRA_SLAVE_MYSQLD_OPT="$EXTRA_SLAVE_MYSQLD_OPT $1"
       ;;
+    --strace-client )
+      STRACE_CLIENT=1
+      ;;        
     --debug)
       EXTRA_MASTER_MYSQLD_OPT="$EXTRA_MASTER_MYSQLD_OPT \
        --debug=d:t:i:O,$MYSQL_TEST_DIR/var/log/master.trace"
@@ -299,6 +302,10 @@
  else
    MYSQL_TEST="$BASEDIR/client/mysqltest"
  fi
+ if [ -n "$STRACE_CLIENT" ]; then
+  MYSQL_TEST="strace -o $MYSQL_TEST_DIR/var/log/mysqltest.strace $MYSQL_TEST"
+ fi
+ 
  MYSQLADMIN="$BASEDIR/client/mysqladmin"
  MYSQL_MANAGER_CLIENT="$BASEDIR/client/mysqlmanagerc"
  MYSQL_MANAGER="$BASEDIR/tools/mysqlmanager"

--- 1.177/sql/sql_parse.cc	Thu Oct 11 09:58:40 2001
+++ 1.178/sql/sql_parse.cc	Fri Oct 12 09:37:24 2001
@@ -938,10 +938,12 @@
       pos = uint4korr(packet);
       flags = uint2korr(packet + 4);
       pthread_mutex_lock(&LOCK_server_id);
+      thd->server_id=0; /* avoid suicide */
       kill_zombie_dump_threads(slave_server_id = uint4korr(packet+6));
       thd->server_id = slave_server_id;
       pthread_mutex_unlock(&LOCK_server_id);
       mysql_binlog_send(thd, thd->strdup(packet + 10), pos, flags);
+      unregister_slave(thd,1,1);
       // fake COM_QUIT -- if we get here, the thread needs to terminate
       error = TRUE;
       net->error = 0;

--- 1.5/client/mysqlmanagerc.c	Thu Oct 11 13:02:15 2001
+++ 1.6/client/mysqlmanagerc.c	Fri Oct 12 09:37:24 2001
@@ -14,7 +14,7 @@
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
-#define MANAGER_CLIENT_VERSION "1.0"
+#define MANAGER_CLIENT_VERSION "1.1"
 
 #include <my_global.h>
 #include <mysql.h>
@@ -28,7 +28,7 @@
 #include <unistd.h>
 
 #ifndef MYSQL_MANAGER_PORT
-#define MYSQL_MANAGER_PORT 23546
+#define MYSQL_MANAGER_PORT 9305
 #endif
 
 static void die(const char* fmt, ...);

--- 1.2/libmysql/manager.c	Thu Oct 11 13:02:15 2001
+++ 1.3/libmysql/manager.c	Fri Oct 12 09:37:24 2001
@@ -91,6 +91,7 @@
   uint32 ip_addr;
   char msg_buf[MAX_MYSQL_MANAGER_MSG];
   int msg_len;
+  Vio* vio;
 
   if (!host)
     host="localhost";
@@ -105,13 +106,14 @@
     strmov(con->last_error,"Cannot create socket");
     goto err;
   }
-  if (!(con->vio=vio_new(sock,VIO_TYPE_TCPIP,FALSE)))
+  if (!(vio=vio_new(sock,VIO_TYPE_TCPIP,FALSE)))
   {
     con->last_errno=ENOMEM;
     strmov(con->last_error,"Cannot create network I/O object");
     goto err;
   }
-  vio_blocking(con->vio,TRUE);
+  vio_blocking(vio,TRUE);
+  my_net_init(&con->net,vio);
   bzero((char*) &sock_addr,sizeof(sock_addr));
   sock_addr.sin_family = AF_INET;
   if ((int) (ip_addr = inet_addr(host)) != (int) INADDR_NONE)
@@ -155,7 +157,7 @@
     goto err;
   }
   /* read the greating */
-  if (vio_read(con->vio,msg_buf,MAX_MYSQL_MANAGER_MSG)<=0)
+  if (my_net_read(&con->net) == packet_error)
   {
     con->last_errno=errno;
     strmov(con->last_error,"Read error on socket");
@@ -163,19 +165,19 @@
   }
   sprintf(msg_buf,"%-.16s %-.16s\n",user,passwd);
   msg_len=strlen(msg_buf);
-  if (vio_write(con->vio,msg_buf,msg_len)!=msg_len)
+  if (my_net_write(&con->net,msg_buf,msg_len) || net_flush(&con->net))
   {
-    con->last_errno=errno;
+    con->last_errno=con->net.last_errno;
     strmov(con->last_error,"Write error on socket");
     goto err;
   }
-  if (vio_read(con->vio,msg_buf,MAX_MYSQL_MANAGER_MSG)<=0)
+  if (my_net_read(&con->net) == packet_error)
   {
     con->last_errno=errno;
     strmov(con->last_error,"Read error on socket");
     goto err;
   }
-  if ((con->cmd_status=atoi(msg_buf)) != MANAGER_OK)
+  if ((con->cmd_status=atoi(con->net.read_pos)) != MANAGER_OK)
   {
     strmov(con->last_error,"Access denied");
     goto err;
@@ -210,11 +212,7 @@
      allocated in my_multimalloc() along with con->host, freeing
      con->hosts frees the whole block
   */
-  if (con->vio)
-  {
-    vio_delete(con->vio);
-    con->vio=0;
-  }
+  net_end(&con->net);
   if (con->free_me)
     my_free((gptr)con,MYF(0));
 }
@@ -224,7 +222,7 @@
 {
   if (!cmd_len)
     cmd_len=strlen(cmd);
-  if (vio_write(con->vio,(char*)cmd,cmd_len) != cmd_len)
+  if (my_net_write(&con->net,(char*)cmd,cmd_len) || net_flush(&con->net))
   {
     con->last_errno=errno;
     strmov(con->last_error,"Write error on socket");
@@ -238,9 +236,9 @@
 						 int res_buf_size)
 {
   char* res_buf_end=res_buf+res_buf_size;
-  char* net_buf_pos=con->net_buf_pos, *net_buf_end=con->net_data_end;
+  char* net_buf=con->net.read_pos, *net_buf_end;
   int res_buf_shift=RES_BUF_SHIFT;
-  int done=0;
+  uint num_bytes;
   
   if (res_buf_size<RES_BUF_SHIFT)
   {
@@ -249,50 +247,26 @@
     return 1;
   }
   
-  for (;;)
+  if ((num_bytes=my_net_read(&con->net)) == packet_error)
   {
-    for (;net_buf_pos<net_buf_end && res_buf<res_buf_end;
-	 net_buf_pos++,res_buf++)
-    {
-      char c=*net_buf_pos;
-      if (c == '\r')
-	c=*++net_buf_pos;
-      if (c == '\n')
-      {
-	*res_buf=0;
-	net_buf_pos++;
-	done=1;
-	break;
-      }
-      else
-	*res_buf=*net_buf_pos;
-    }
-    if (done || res_buf==res_buf_end)
-      break;
-      
-    if (net_buf_pos == net_buf_end && res_buf<res_buf_end)
-    {
-      int num_bytes;
-      if ((num_bytes=vio_read(con->vio,con->net_buf,con->net_buf_size))<=0)
-      {
-	con->last_errno=errno;
-	strmov(con->last_error,"socket read failed");
-	return 1;
-      }
-      net_buf_pos=con->net_buf;
-      net_buf_end=net_buf_pos+num_bytes;
-    }
+    con->last_errno=errno;
+    strmov(con->last_error,"socket read failed");
+    return 1;
   }
-  con->net_buf_pos=net_buf_pos;
-  con->net_data_end=net_buf_end;
-  res_buf=res_buf_end-res_buf_size;
-  if ((con->eof=(res_buf[3]==' ')))
+
+  net_buf_end=net_buf+num_bytes;
+  
+  if ((con->eof=(net_buf[3]==' ')))
     res_buf_shift--;
-  res_buf_end-=res_buf_shift;
-  for (;res_buf<res_buf_end;res_buf++)
+  net_buf+=res_buf_shift;
+  res_buf_end[-1]=0;
+  for (;net_buf<net_buf_end && res_buf < res_buf_end;res_buf++,net_buf++)
   {
-    if(!(*res_buf=res_buf[res_buf_shift]))
+    if((*res_buf=*net_buf) == '\r')
+    {
+      *res_buf=0;
       break;
+    }
   }
   return 0;
 }

--- 1.59/sql/sql_repl.cc	Wed Oct  3 13:55:31 2001
+++ 1.60/sql/sql_repl.cc	Fri Oct 12 09:37:24 2001
@@ -106,10 +106,25 @@
   p+= len; \
 }\
 
+void unregister_slave(THD* thd, bool only_mine, bool need_mutex)
+{
+  if (need_mutex)
+    pthread_mutex_lock(&LOCK_slave_list);
+  if (thd->server_id)
+  {
+    SLAVE_INFO* old_si;
+    if ((old_si = (SLAVE_INFO*)hash_search(&slave_list,
+					   (byte*)&thd->server_id, 4)) &&
+	(!only_mine || old_si->thd == thd))
+    hash_delete(&slave_list, (byte*)old_si);
+  }
+  if (need_mutex)
+    pthread_mutex_unlock(&LOCK_slave_list);
+}
 
 int register_slave(THD* thd, uchar* packet, uint packet_length)
 {
-  SLAVE_INFO *si, *old_si;
+  SLAVE_INFO *si;
   int res = 1;
   uchar* p = packet, *p_end = packet + packet_length;
 
@@ -119,18 +134,16 @@
   if (!(si = (SLAVE_INFO*)my_malloc(sizeof(SLAVE_INFO), MYF(MY_WME))))
     goto err;
 
-  si->server_id = uint4korr(p);
+  thd->server_id = si->server_id = uint4korr(p);
   p += 4;
   get_object(p,si->host);
   get_object(p,si->user);
   get_object(p,si->password);
   si->port = uint2korr(p);
+  si->thd = thd;
   pthread_mutex_lock(&LOCK_slave_list);
 
-  if ((old_si = (SLAVE_INFO*)hash_search(&slave_list,
-					(byte*)&si->server_id, 4)))
-     hash_delete(&slave_list, (byte*)old_si);
-
+  unregister_slave(thd,0,0);
   res = hash_insert(&slave_list, (byte*) si);
   pthread_mutex_unlock(&LOCK_slave_list);
   return res;

--- 1.12/sql/sql_repl.h	Fri Aug  3 15:57:52 2001
+++ 1.13/sql/sql_repl.h	Fri Oct 12 09:37:24 2001
@@ -10,6 +10,7 @@
   char user[USERNAME_LENGTH+1];
   char password[HASH_PASSWORD_LENGTH+1];
   uint16 port;
+  THD* thd;
 } SLAVE_INFO;
 
 extern bool opt_show_slave_auth_info, opt_old_rpl_compat;
@@ -44,6 +45,7 @@
 void init_slave_list();
 void end_slave_list();
 int register_slave(THD* thd, uchar* packet, uint packet_length);
+void unregister_slave(THD* thd, bool only_mine, bool need_mutex);
 int purge_master_logs(THD* thd, const char* to_log);
 bool log_in_use(const char* log_name);
 void adjust_linfo_offsets(my_off_t purge_offset);

--- 1.19/tools/mysqlmanager.c	Thu Oct 11 13:02:15 2001
+++ 1.20/tools/mysqlmanager.c	Fri Oct 12 09:37:24 2001
@@ -133,7 +133,7 @@
 
 struct manager_thd
 {
-  Vio* vio;
+  NET net;
   char user[MAX_USER_NAME+1];
   int priv_flags;
   char* cmd_buf;
@@ -154,7 +154,7 @@
 static struct manager_thd* manager_thd_new(Vio* vio);
 
 static struct manager_exec* manager_exec_new(char* arg_start,char* arg_end);
-static void manager_exec_print(Vio* vio,struct manager_exec* e);
+static void manager_exec_print(NET* net,struct manager_exec* e);
 static void manager_thd_free(struct manager_thd* thd);
 static void manager_exec_free(void* e);
 static void manager_exec_connect(struct manager_exec* e);
@@ -291,9 +291,9 @@
 static void print_time(FILE* fp);
 static void clean_up();
 static struct manager_cmd* lookup_cmd(char* s,int len);
-static void client_msg(Vio* vio,int err_code,const char* fmt,...);
-static void client_msg_pre(Vio* vio,int err_code,const char* fmt,...);
-static void client_msg_raw(Vio* vio,int err_code,int pre,const char* fmt,
+static void client_msg(NET* net,int err_code,const char* fmt,...);
+static void client_msg_pre(NET* net,int err_code,const char* fmt,...);
+static void client_msg_raw(NET* net,int err_code,int pre,const char* fmt,
 			    va_list args);
 static int authenticate(struct manager_thd* thd);
 static char* read_line(struct manager_thd* thd); /* returns pointer to end of
@@ -371,7 +371,7 @@
     *p=tolower(*p);
   if (!(cmd=lookup_cmd(buf,(int)(p-buf))))
   {
-    client_msg(thd->vio,MANAGER_CLIENT_ERR,
+    client_msg(&thd->net,MANAGER_CLIENT_ERR,
 	       "Unrecognized command, type help to see list of supported\
  commands");
     return 1;
@@ -393,13 +393,13 @@
 
 HANDLE_NOARG_DECL(handle_ping)
 {
-  client_msg(thd->vio,MANAGER_OK,"Server management daemon is alive");
+  client_msg(&thd->net,MANAGER_OK,"Server management daemon is alive");
   return 0;
 }
 
 HANDLE_NOARG_DECL(handle_quit)
 {
-  client_msg(thd->vio,MANAGER_OK,"Goodbye");
+  client_msg(&thd->net,MANAGER_OK,"Goodbye");
   thd->finished=1;
   return 0;
 }
@@ -407,19 +407,19 @@
 HANDLE_NOARG_DECL(handle_help)
 {
   struct manager_cmd* cmd = commands;
-  Vio* vio = thd->vio;
-  client_msg_pre(vio,MANAGER_INFO,"Available commands:");
+  NET* net = &thd->net;
+  client_msg_pre(net,MANAGER_INFO,"Available commands:");
   for (;cmd->name;cmd++)
   {
-    client_msg_pre(vio,MANAGER_INFO,"%s - %s", cmd->name, cmd->help);
+    client_msg_pre(net,MANAGER_INFO,"%s - %s", cmd->name, cmd->help);
   }
-  client_msg_pre(vio,MANAGER_INFO,"End of help");
+  client_msg_pre(net,MANAGER_INFO,"End of help");
   return 0;
 }
 
 HANDLE_NOARG_DECL(handle_shutdown)
 {
-  client_msg(thd->vio,MANAGER_OK,"Shutdown started, goodbye");
+  client_msg(&thd->net,MANAGER_OK,"Shutdown started, goodbye");
   thd->finished=1;
   shutdown_requested = 1;
   if (!one_thread)
@@ -470,10 +470,10 @@
     }
   }
   pthread_mutex_unlock(&lock_exec_hash);
-  client_msg(thd->vio,MANAGER_OK,"Entry updated");
+  client_msg(&thd->net,MANAGER_OK,"Entry updated");
   return 0;
 err:
-  client_msg(thd->vio,MANAGER_CLIENT_ERR,error);
+  client_msg(&thd->net,MANAGER_CLIENT_ERR,error);
   return 1;
 }
 
@@ -531,10 +531,10 @@
   }
   strnmov(param,arg_p,FN_REFLEN);
   pthread_mutex_unlock(&lock_exec_hash);
-  client_msg(thd->vio,MANAGER_OK,"Entry updated");
+  client_msg(&thd->net,MANAGER_OK,"Entry updated");
   return 0;
 err:
-  client_msg(thd->vio,MANAGER_CLIENT_ERR,error);
+  client_msg(&thd->net,MANAGER_CLIENT_ERR,error);
   return 1;
 }
 
@@ -581,10 +581,10 @@
   pthread_mutex_unlock(&e->lock);
   if (error)
     goto err;
-  client_msg(thd->vio,MANAGER_OK,"'%s' started",e->ident);
+  client_msg(&thd->net,MANAGER_OK,"'%s' started",e->ident);
   return 0;
 err:
-  client_msg(thd->vio,MANAGER_CLIENT_ERR,error);
+  client_msg(&thd->net,MANAGER_CLIENT_ERR,error);
   return 1;
 }
 
@@ -636,11 +636,11 @@
   pthread_mutex_unlock(&e->lock);
   if (!error)
   {
-    client_msg(thd->vio,MANAGER_OK,"'%s' terminated",e->ident);
+    client_msg(&thd->net,MANAGER_OK,"'%s' terminated",e->ident);
     return 0;
   }
 err:
-  client_msg(thd->vio,MANAGER_CLIENT_ERR,error);
+  client_msg(&thd->net,MANAGER_CLIENT_ERR,error);
   return 1;
 }
 
@@ -705,7 +705,7 @@
       *p++='\t';
     }
     *p=0;
-    client_msg_pre(thd->vio,MANAGER_OK,buf);
+    client_msg_pre(&thd->net,MANAGER_OK,buf);
     
     while ((row=mysql_fetch_row(res)))
     {
@@ -716,14 +716,14 @@
 	*p++='\t';
       }
       *p=0;
-      client_msg_pre(thd->vio,MANAGER_OK,buf);
+      client_msg_pre(&thd->net,MANAGER_OK,buf);
     }
   }
   pthread_mutex_unlock(&e->lock);
-  client_msg(thd->vio,MANAGER_OK,"End");
+  client_msg(&thd->net,MANAGER_OK,"End");
   return 0;
 err:
-  client_msg(thd->vio,MANAGER_CLIENT_ERR,error);
+  client_msg(&thd->net,MANAGER_CLIENT_ERR,error);
   return 1;
 }
 
@@ -756,10 +756,10 @@
   }
   hash_insert(&exec_hash,(byte*)e);
   pthread_mutex_unlock(&lock_exec_hash);
-  client_msg(thd->vio,MANAGER_OK,"Exec definition created");
+  client_msg(&thd->net,MANAGER_OK,"Exec definition created");
   return 0;
 err:
-  client_msg(thd->vio,MANAGER_CLIENT_ERR,error);
+  client_msg(&thd->net,MANAGER_CLIENT_ERR,error);
   if (e)
     manager_exec_free(e);
   return 1;
@@ -768,16 +768,16 @@
 HANDLE_NOARG_DECL(handle_show_exec)
 {
   uint i;
-  client_msg_pre(thd->vio,MANAGER_INFO,"Exec_def\tPid\tExit_status\tCon_info\
+  client_msg_pre(&thd->net,MANAGER_INFO,"Exec_def\tPid\tExit_status\tCon_info\
 \tStdout\tStderr\tArguments");
   pthread_mutex_lock(&lock_exec_hash);
   for (i=0;i<exec_hash.records;i++)
   {
     struct manager_exec* e=(struct manager_exec*)hash_element(&exec_hash,i);
-    manager_exec_print(thd->vio,e);
+    manager_exec_print(&thd->net,e);
   }
   pthread_mutex_unlock(&lock_exec_hash);
-  client_msg(thd->vio,MANAGER_INFO,"End");
+  client_msg(&thd->net,MANAGER_INFO,"End");
   return 0;
 }
 
@@ -873,7 +873,7 @@
   return dest;
 }
 
-static void manager_exec_print(Vio* vio,struct manager_exec* e)
+static void manager_exec_print(NET* net,struct manager_exec* e)
 {
   char buf[MAX_MYSQL_MANAGER_MSG];
   char* p=buf,*buf_end=buf+sizeof(buf)-1;
@@ -921,7 +921,7 @@
   }
 end:  
   *p=0;
-  client_msg_pre(vio,MANAGER_INFO,buf);
+  client_msg_pre(net,MANAGER_INFO,buf);
   return;
 }
 
@@ -933,7 +933,7 @@
   struct manager_user* u;
   char c;
   
-  client_msg(thd->vio,MANAGER_INFO, manager_greeting);
+  client_msg(&thd->net,MANAGER_INFO, manager_greeting);
   if (!(buf_end=read_line(thd)))
     return -1;
   for (buf=thd->cmd_buf,p=thd->user,p_end=p+MAX_USER_NAME;
@@ -959,7 +959,7 @@
   my_MD5Final(digest,&context);
   if (memcmp(u->md5_pass,digest,MD5_LEN))
     return 1;
-  client_msg(thd->vio,MANAGER_OK,"OK");
+  client_msg(&thd->net,MANAGER_OK,"OK");
   return 0;
 }
 
@@ -1121,7 +1121,7 @@
   return 0;					/* Don't get cc warning */
 }
 
-static void client_msg_raw(Vio* vio, int err_code, int pre, const char* fmt,
+static void client_msg_raw(NET* net, int err_code, int pre, const char* fmt,
 			   va_list args)
 {
   char buf[MAX_CLIENT_MSG_LEN],*p,*buf_end;
@@ -1136,73 +1136,44 @@
     p=buf_end - 2;
   *p++='\r';
   *p++='\n';
-  if (vio_write(vio,buf,(uint)(p-buf))<=0)
-    log_err("Failed writing to client: errno=%d",errno);
+  if (my_net_write(net,buf,(uint)(p-buf)) || net_flush(net))
+    log_err("Failed writing to client: errno=%d",net->last_errno);
 }
 
-static void client_msg(Vio* vio, int err_code, const char* fmt, ...)
+static void client_msg(NET* net, int err_code, const char* fmt, ...)
 {
   va_list args;
   va_start(args,fmt);
-  client_msg_raw(vio,err_code,0,fmt,args);
+  client_msg_raw(net,err_code,0,fmt,args);
 }
 
-static void client_msg_pre(Vio* vio, int err_code, const char* fmt, ...)
+static void client_msg_pre(NET* net, int err_code, const char* fmt, ...)
 {
   va_list args;
   va_start(args,fmt);
-  client_msg_raw(vio,err_code,1,fmt,args);
+  client_msg_raw(net,err_code,1,fmt,args);
 }
 
 static char* read_line(struct manager_thd* thd)
 {
-  char* p=thd->cmd_buf;
-  char* buf_end = thd->cmd_buf + manager_max_cmd_len;
-  int escaped = 0;
-  for (;p<buf_end;)
-  {
-    int len,read_len;
-    char *block_end,*p_back;
-    uint retry_count=0;
-
-    read_len = min(NET_BLOCK,(uint)(buf_end-p));
-    while ((len=vio_read(thd->vio,p,read_len))<=0)
+  uint len;
+  char* p, *buf_end;
+  if ((len=my_net_read(&thd->net)) == packet_error)
     {
-      if (vio_should_retry(thd->vio) && retry_count++ < MAX_RETRY_COUNT)
-	continue;
       log_err("Error reading command from client (Error: %d)",
-	      vio_errno(thd->vio));
+	      errno);
       thd->fatal=1;
       return 0;
     }
-    block_end=p+len;
-    /* a trick to unescape in place */
-    for (p_back=p;p<block_end;p++)
-    {
-      char c=*p;
-      if (c==ESCAPE_CHAR)
-      {
-	if (!escaped)
-	{
-	  escaped=1;
-	  continue;
-	}
-	else
-	  escaped=0;
-      }
-      if (c==EOL_CHAR && !escaped)
-	break;
-      *p_back++=c;
-      escaped=0;
-    }
-    if (p!=block_end)
+  buf_end=thd->cmd_buf+len;
+  for (p=thd->cmd_buf;p<buf_end;p++)
+    if (*p == '\r' || *p == '\n')
     {
-      *p_back=0;
-      return p_back;
+      *p=0;
+      break;
     }
-  }
-  client_msg(thd->vio,MANAGER_CLIENT_ERR,"Command line too long");
-  return 0;
+  
+  return p;
 }
 
 static void handle_child(int __attribute__((unused)) sig)
@@ -1225,25 +1196,23 @@
 struct manager_thd* manager_thd_new(Vio* vio)
 {
   struct manager_thd* tmp;
-  if (!(tmp=(struct manager_thd*)my_malloc(sizeof(*tmp)+manager_max_cmd_len,
+  if (!(tmp=(struct manager_thd*)my_malloc(sizeof(*tmp),
 					MYF(0))))
   {
     log_err("Out of memory in manager_thd_new");
     return 0;
   }
-  tmp->vio=vio;
+  my_net_init(&tmp->net,vio);
   tmp->user[0]=0;
   tmp->priv_flags=0;
   tmp->fatal=tmp->finished=0;
-  tmp->cmd_buf=(char*)tmp+sizeof(*tmp);
+  tmp->cmd_buf=tmp->net.read_pos;
   return tmp;
 }
 
 static void manager_thd_free(struct manager_thd* thd)
 {
-  if (thd->vio)
-    vio_close(thd->vio);
-  my_free((byte*)thd->vio,MYF(0));
+  net_end(&thd->net);
 }
 
 static void clean_up()
@@ -1413,7 +1382,7 @@
     
     if (authenticate(thd))
     {
-      client_msg(vio,MANAGER_ACCESS, "Access denied");
+      client_msg(&thd->net,MANAGER_ACCESS, "Access denied");
       manager_thd_free(thd);
       continue;
     }
@@ -1427,7 +1396,8 @@
     }
     else if (pthread_create(&th,&thr_attr,process_connection,(void*)thd))
     {
-      client_msg(vio,MANAGER_INTERNAL_ERR,"Could not create thread, errno=%d",
+      client_msg(&thd->net,MANAGER_INTERNAL_ERR,
+		 "Could not create thread, errno=%d",
 		 errno);
       manager_thd_free(thd);
       continue;
Thread
bk commit into 4.0 treesasha12 Oct