List:Internals« Previous MessageNext Message »
From:sasha Date:September 23 2001 3:48am
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-09-22 21:47:57-06:00, sasha@stripped
  added mysqlmanager-pwgen
  added set_exec_stdout and set_exec_stderr to mysqlmanager to be able 
  to redirect stdout and stderr
  added support for MY_FULL_IO to my_read, so we can tell it to read
  a number of bytes in as many chunks as it takes instead of one try

  client/mysqlmanager-pwgen.c
    1.1 01/09/22 21:47:56 sasha@stripped +153 -0

  BitKeeper/etc/ignore
    1.94 01/09/22 21:47:56 sasha@stripped +1 -0
    Added client/mysqlmanager-pwgen to the ignore list

  client/Makefile.am
    1.21 01/09/22 21:47:56 sasha@stripped +1 -1
    mysqlmanager-pwgen

  client/mysqlmanager-pwgen.c
    1.0 01/09/22 21:47:56 sasha@stripped +0 -0
    BitKeeper file /home/sasha/src/bk/mysql-4.0/client/mysqlmanager-pwgen.c

  client/mysqlmanagerc.c
    1.3 01/09/22 21:47:56 sasha@stripped +3 -3
    clean-up

  include/my_sys.h
    1.51 01/09/22 21:47:56 sasha@stripped +3 -0
    added MY_FULL_IO

  mysql-test/mysql-test-run.sh
    1.100 01/09/22 21:47:56 sasha@stripped +31 -0
    started on changes to use mysqlmanager

  mysys/my_read.c
    1.4 01/09/22 21:47:56 sasha@stripped +12 -2
    added support for MY_FULL_IO

  tools/managertest1.nc
    1.3 01/09/22 21:47:56 sasha@stripped +2 -0
    updated test case

  tools/mysqlmanager.c
    1.10 01/09/22 21:47:56 sasha@stripped +138 -21
    added set_exec_stdout and set_exec_stderr

# 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.20/client/Makefile.am	Wed Sep 19 14:39:10 2001
+++ 1.21/client/Makefile.am	Sat Sep 22 21:47:56 2001
@@ -23,7 +23,7 @@
 LIBS =				@CLIENT_LIBS@
 LDADD =				@CLIENT_EXTRA_LDFLAGS@ ../libmysql/libmysqlclient.la
 bin_PROGRAMS =			mysql mysqladmin mysqlcheck mysqlshow \
- mysqldump mysqlimport mysqltest mysqlbinlog mysqlmanagerc
+ mysqldump mysqlimport mysqltest mysqlbinlog mysqlmanagerc mysqlmanager-pwgen
 noinst_PROGRAMS =		insert_test select_test thread_test
 noinst_HEADERS =		sql_string.h completion_hash.h my_readline.h
 mysql_SOURCES =			mysql.cc readline.cc sql_string.cc completion_hash.cc

--- 1.50/include/my_sys.h	Sun Sep  2 08:32:57 2001
+++ 1.51/include/my_sys.h	Sat Sep 22 21:47:56 2001
@@ -59,6 +59,9 @@
 #define MY_WME		16	/* Write message on error */
 #define MY_WAIT_IF_FULL 32	/* Wait and try again if disk full error */
 #define MY_RAID         64      /* Support for RAID (not the "Johnson&Johnson"-s one ;) */
+#define MY_FULL_IO     128      /* For my_read - loop intil I/O
+				   is complete
+				*/
 #define MY_DONT_CHECK_FILESIZE 128	/* Option to init_io_cache() */
 #define MY_LINK_WARNING 32	/* my_redel() gives warning if links */
 #define MY_COPYTIME	64	/* my_redel() copys time */

--- 1.99/mysql-test/mysql-test-run.sh	Mon Sep 17 20:17:51 2001
+++ 1.100/mysql-test/mysql-test-run.sh	Sat Sep 22 21:47:56 2001
@@ -118,6 +118,7 @@
 MASTER_MYPORT=9306
 SLAVE_RUNNING=0
 SLAVE_MYPORT=9307
+MYSQL_MANAGER_PORT=23546
 NO_SLAVE=0
 
 EXTRA_MASTER_OPT=""
@@ -276,6 +277,9 @@
    MYSQL_TEST="$BASEDIR/client/mysqltest"
  fi
  MYSQLADMIN="$BASEDIR/client/mysqladmin"
+ MYSQL_MANAGER_CLIENT="$BASEDIR/client/mysqlmanagerc"
+ MYSQL_MANAGER="$BASEDIR/tools/mysqlmanager"
+ MYSQL_MANAGER_PWGEN="$BASEDIR/client/mysqlmanager-pwgen"
  MYSQL="$BASEDIR/client/mysql"
  LANGUAGE="$BASEDIR/sql/share/english/"
  CHARSETSDIR="$BASEDIR/sql/share/charsets"
@@ -284,6 +288,9 @@
  MYSQLD="$BASEDIR/bin/mysqld"
  MYSQL_TEST="$BASEDIR/bin/mysqltest"
  MYSQLADMIN="$BASEDIR/bin/mysqladmin"
+ MYSQL_MANAGER="$BASEDIR/bin/mysqlmanager"
+ MYSQL_MANAGER_CLIENT="$BASEDIR/bin/mysqlmanagerc"
+ MYSQL_MANAGER_PWGEN="$BASEDIR/bin/mysqlmanager-pwgen"
  MYSQL="$BASEDIR/bin/mysql"
  INSTALL_DB="./install_test_db -bin"
  if test -d "$BASEDIR/share/mysql/english" 
@@ -487,6 +494,30 @@
     $ECHO "gcov info in $GCOV_MSG, errors in $GCOV_ERR"
 }
 
+abort_if_failed()
+{
+ if [ ! $? = 0 ] ; then
+  echo $1
+  exit 1
+ fi 
+}
+
+start_manager()
+{
+ MYSQL_MANAGER_PW=`$MYSQL_MANAGER_PWGEN -o $MYSQL_MANAGER_PW_FILE` 
+ $MYSQL_MANAGER --log=$MYSQL_MANAGER_LOG --port=$MYSQL_MANAGER_PORT \
+  --password-file=$MYSQL_MANAGER_PW_FILE
+  abort_if_failed "Could not start MySQL manager"
+}
+
+manager_cmd()
+{
+  $MYSQL_MANAGER_CLIENT --user=$MYSQL_MANAGER_USER \
+   --password=$MYSQL_MANAGER_PW  --port=$MYSQL_MANAGER_PORT <<EOF
+$@
+EOF
+ abort_if_failed "Could not execute manager command"
+}
 
 start_master()
 {

--- 1.3/mysys/my_read.c	Wed Aug 30 13:42:02 2000
+++ 1.4/mysys/my_read.c	Sat Sep 22 21:47:56 2001
@@ -28,10 +28,11 @@
 				/* Max number of bytes returnd */
 				/* Flags on what to do on error */
 {
-  uint readbytes;
+  uint readbytes,save_count;
   DBUG_ENTER("my_read");
   DBUG_PRINT("my",("Fd: %d  Buffer: %lx  Count: %u  MyFlags: %d",
 		   Filedes, Buffer, Count, MyFlags));
+  save_count=Count;
 
   for (;;)
   {
@@ -54,12 +55,21 @@
 	  my_error(EE_EOFERR, MYF(ME_BELL+ME_WAITTANG),
 		   my_filename(Filedes),my_errno);
       }
-      if ((int) readbytes == -1 || (MyFlags & (MY_FNABP | MY_NABP)))
+      if ((int) readbytes == -1 ||
+	  ((MyFlags & (MY_FNABP | MY_NABP)) && !(MyFlags & MY_FULL_IO)))
 	DBUG_RETURN(MY_FILE_ERROR);	/* Return with error */
+      if (readbytes > 0 && (MyFlags & MY_FULL_IO))
+      {
+	Buffer+=readbytes;
+	Count-=readbytes;
+	continue;
+      }
     }
 
     if (MyFlags & (MY_NABP | MY_FNABP))
       readbytes=0;			/* Ok on read */
+    else if (MyFlags & MY_FULL_IO)
+      readbytes=save_count;
     break;
   }
   DBUG_RETURN(readbytes);

--- 1.93/BitKeeper/etc/ignore	Wed Sep 19 14:33:35 2001
+++ 1.94/BitKeeper/etc/ignore	Sat Sep 22 21:47:56 2001
@@ -413,3 +413,4 @@
 vio/test-sslclient
 vio/test-sslserver
 vio/viotest-ssl
+client/mysqlmanager-pwgen
--- New file ---
+++ client/mysqlmanager-pwgen.c	01/09/22 21:47:56
/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   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_PWGEN_VERSION "1.0"

#include <my_global.h>
#include <m_ctype.h>
#include <my_sys.h>
#include <m_string.h>
#include <mysql_version.h>
#include <errno.h>
#include <getopt.h>
#include <md5.h>

const char* outfile=0,*user="root";

struct option long_options[] =
{
  {"output-file",required_argument,0,'o'},
  {"user",required_argument,0,'u'},
  {"help",no_argument,0,'?'},
  {"version",no_argument,0,'V'},
  {0,0,0,0}
};

static void die(const char* fmt, ...)
{
  va_list args;
  DBUG_ENTER("die");
  va_start(args, fmt);
  if (fmt)
  {
    fprintf(stderr, "%s: ", my_progname);
    vfprintf(stderr, fmt, args);
    fprintf(stderr, "\n");
    fflush(stderr);
  }
  va_end(args);
  exit(1);
}

static void print_version(void)
{
  printf("%s  Ver %s Distrib %s, for %s (%s)\n",my_progname,
	 MANAGER_PWGEN_VERSION,
	 MYSQL_SERVER_VERSION,SYSTEM_TYPE,MACHINE_TYPE);
}

void usage()
{
  print_version();
  printf("MySQL AB, by Sasha\n");
  printf("This software comes with ABSOLUTELY NO WARRANTY\n\n");
  printf("Generates a password file to be used by mysqltest.\n\n");
  printf("Usage: %s [OPTIONS]\n", my_progname);
  printf("-?,--help     Display this message and exit\n\
-V,--version    Display version info\n\
-u,--user=      Put given user in the password file\n\
-o,--output-file= Write the output to the file with the given name\n");
}

int parse_args(int argc, char** argv)
{
  int c,option_index=0;
  while ((c=getopt_long(argc,argv,"?Vu:o:",long_options,&option_index))
	 != EOF)
  {
    switch (c)
    {
    case 'o':
      outfile=optarg;
      break;
    case 'u':
      user=optarg;
      break;
    case '?':
      usage();
      exit(0);
    case 'V':
      print_version();
      exit(0);
    default:
      usage();
      exit(1);
    }
  }
  return 0;
}

void get_pass(char* pw, int len)
{
  FILE* fp;
  char* pw_end=pw+len;
/* /dev/random is more secure than  rand() because the seed is easy to
 predict, so we resort to rand() only if /dev/random is not available */
  if ((fp=fopen("/dev/random","r")))
  {
    fread(pw,len,1,fp);
    fclose(fp);
    while (pw<pw_end)
    {
      *pw++='a'+((uint)*pw % 26);
    }
  }
  else
  {
    srand(time(NULL));
    while (pw<pw_end)
      *pw++='a'+((uint)rand() % 26);
  }
  *pw_end=0;
}

int main(int argc, char** argv)
{
  FILE* fp;
  my_MD5_CTX context;
  uchar digest[16];
  char pw[17];
  uint i;
  
  MY_INIT(argv[0]);
  parse_args(argc,argv);
  if (!outfile)
    die("Missing --output-file");
  
  if (!(fp=fopen(outfile,"w")))
    die("Could not open '%s'(errno=%d)",outfile,errno);
  get_pass(pw,sizeof(pw)-1);
  my_MD5Init(&context);
  my_MD5Update(&context,pw,sizeof(pw)-1);
  my_MD5Final(digest,&context);
  fprintf(fp,"%s:",user);
  for (i=0;i<sizeof(digest);i++)
    fprintf(fp,"%02x",digest[i]);
  fprintf(fp,"\n");
  fclose(fp);
  printf("%s\n",pw);
  return 0;
}


--- 1.2/client/mysqlmanagerc.c	Wed Sep 19 19:45:12 2001
+++ 1.3/client/mysqlmanagerc.c	Sat Sep 22 21:47:56 2001
@@ -92,9 +92,9 @@
 void usage()
 {
   print_version();
-  printf("MySQL AB, by Sasha, Matt & Monty\n");
+  printf("MySQL AB, by Sasha\n");
   printf("This software comes with ABSOLUTELY NO WARRANTY\n\n");
-  printf("Runs a test against the mysql server and compares output with a results file.\n\n");
+  printf("Command-line client for MySQL manager daemon.\n\n");
   printf("Usage: %s [OPTIONS] < command_file\n", my_progname);
   printf("\n\
   -?, --help               Display this help and exit.\n");
@@ -148,7 +148,7 @@
 	exit(0);
       case '?':
 	usage();
-	exit(1);				/* Unknown option */
+	exit(0);				
       default:
 	usage();
 	exit(1);

--- 1.2/tools/managertest1.nc	Wed Sep 19 14:30:41 2001
+++ 1.3/tools/managertest1.nc	Sat Sep 22 21:47:56 2001
@@ -1,5 +1,7 @@
 def_exec server /usr/sbin/mysqld --socket=/tmp/temp.sock --skip-grant --skip-net --datadir=/tmp
 set_exec_con server root localhost /tmp/temp.sock
+set_exec_stdout server /tmp/mysqld.err
+set_exec_stderr server /tmp/mysqld.err
 start_exec server 3
 show_exec
 stop_exec server 3

--- 1.9/tools/mysqlmanager.c	Wed Sep 19 19:45:12 2001
+++ 1.10/tools/mysqlmanager.c	Sat Sep 22 21:47:56 2001
@@ -117,6 +117,8 @@
 const char* manager_pw_file=MANAGER_PW_FILE;
 int one_thread = 0; /* for debugging */
 
+typedef enum {PARAM_STDOUT,PARAM_STDERR} PARAM_TYPE;
+
 /* messages */
 
 #define MAX_CLIENT_MSG_LEN  256
@@ -170,6 +172,7 @@
 static uint tokenize_args(char* arg_start,char** arg_end);
 static void init_arg_array(char* arg_str,char** args,uint arg_count);
 static int hex_val(char c);
+static int open_and_dup(int fd,char* path);
 
 typedef int (*manager_cmd_handler)(struct manager_thd*,char*,char*);
 
@@ -211,12 +214,18 @@
   pthread_t th;
   char con_sock[FN_REFLEN];
   char con_host[MAX_HOST];
+  char stderr_path[FN_REFLEN];
+  char stdout_path[FN_REFLEN];
   MYSQL mysql;
   char* data_buf;
   int req_len;
+  int stderr_path_size,stdout_path_size,data_buf_size;
   int num_args;
 };
 
+static int set_exec_param(struct manager_thd* thd, char* args_start,
+			  char* args_end, PARAM_TYPE param_type);
+
 #define HANDLE_DECL(com) static int handle_ ## com (struct manager_thd* thd,\
  char* args_start,char* args_end)
 
@@ -233,6 +242,8 @@
 HANDLE_DECL(start_exec);
 HANDLE_DECL(stop_exec);
 HANDLE_DECL(set_exec_con);
+HANDLE_DECL(set_exec_stdout);
+HANDLE_DECL(set_exec_stderr);
 HANDLE_NOARG_DECL(show_exec);
 
 struct manager_cmd commands[] =
@@ -247,6 +258,10 @@
    handle_stop_exec,9},
   {"set_exec_con", "Set connection parameters for executable entry",
    handle_set_exec_con,12},
+  {"set_exec_stdout", "Set stdout path for executable entry",
+   handle_set_exec_stdout,15},
+  {"set_exec_stderr", "Set stderr path for executable entry",
+   handle_set_exec_stderr,15},
   {"show_exec","Show defined executable entries",handle_show_exec,9},
   {"help", "Print this message", handle_help,4},
   {0,0,0,0}
@@ -460,6 +475,68 @@
   return 1;
 }
 
+HANDLE_DECL(set_exec_stdout)
+{
+  return set_exec_param(thd,args_start,args_end,PARAM_STDOUT);
+}
+
+HANDLE_DECL(set_exec_stderr)
+{
+  return set_exec_param(thd,args_start,args_end,PARAM_STDERR);
+}
+
+static int set_exec_param(struct manager_thd* thd, char* args_start,
+			  char* args_end, PARAM_TYPE param_type)
+{
+  int num_args;
+  const char* error=0;
+  struct manager_exec* e;
+  char* arg_p;
+  char* param;
+  int param_size;
+  
+  if ((num_args=tokenize_args(args_start,&args_end))<2)
+  {
+    error="Too few arguments";
+    goto err;
+  }
+  arg_p=args_start;
+  pthread_mutex_lock(&lock_exec_hash);
+  if (!(e=(struct manager_exec*)hash_search(&exec_hash,arg_p,
+					    strlen(arg_p))))
+  {
+    pthread_mutex_unlock(&lock_exec_hash);
+    error="Exec definition entry does not exist";
+    goto err;
+  }
+  arg_p+=strlen(arg_p)+1;
+  param_size=strlen(arg_p)+1;
+  switch (param_type)
+  {
+  case PARAM_STDOUT:
+    param=e->stdout_path;
+    e->req_len+=(param_size-e->stdout_path_size);
+    e->stdout_path_size=param_size;
+    break;
+  case PARAM_STDERR:
+    param=e->stderr_path;
+    e->req_len+=(param_size-e->stderr_path_size);
+    e->stderr_path_size=param_size;
+    break;
+  default:
+    error="Internal error";
+    goto err;
+  }
+  strnmov(param,arg_p,FN_REFLEN);
+  pthread_mutex_unlock(&lock_exec_hash);
+  client_msg(thd->vio,MANAGER_OK,"Entry updated");
+  return 0;
+err:
+  client_msg(thd->vio,MANAGER_CLIENT_ERR,error);
+  return 1;
+}
+
+
 HANDLE_DECL(start_exec)
 {
   int num_args;
@@ -488,7 +565,8 @@
   pthread_mutex_lock(&e->lock);
   t.tv_sec=time(0)+atoi(args_start+ident_len+1);
   t.tv_nsec=0;
-  pthread_cond_timedwait(&e->cond,&e->lock,&t);
+  if (!e->pid)
+    pthread_cond_timedwait(&e->cond,&e->lock,&t);
   if (!e->pid)
   {
     pthread_mutex_unlock(&e->lock);
@@ -548,7 +626,8 @@
     error="Could not send shutdown command";
     goto err;
   }
-  pthread_cond_timedwait(&e->cond,&e->lock,&abstime);
+  if (e->pid)
+    pthread_cond_timedwait(&e->cond,&e->lock,&abstime);
   if (e->pid)
     error="Process failed to terminate within alotted time";
   e->th=0;
@@ -600,7 +679,7 @@
 {
   uint i;
   client_msg_pre(thd->vio,MANAGER_INFO,"Exec_def\tPid\tExit_status\tCon_info\
-\tArguments");
+\tStdout\tStderr\tArguments");
   pthread_mutex_lock(&lock_exec_hash);
   for (i=0;i<exec_hash.records;i++)
   {
@@ -668,9 +747,16 @@
   }
   else
   {
-    if (write(to_launcher_pipe[1],&e->req_len,sizeof(int))!=sizeof(int) ||
-	write(to_launcher_pipe[1],&e->num_args,sizeof(int))!=sizeof(int) ||
-	write(to_launcher_pipe[1],e->data_buf,e->req_len)!=e->req_len)
+    if (my_write(to_launcher_pipe[1],(byte*)&e->req_len,
+		 sizeof(int),MYF(MY_NABP))||
+	my_write(to_launcher_pipe[1],(byte*)&e->num_args,
+		 sizeof(int),MYF(MY_NABP)) ||
+	my_write(to_launcher_pipe[1],e->stdout_path,e->stdout_path_size,
+		 MYF(MY_NABP)) ||
+	my_write(to_launcher_pipe[1],e->stderr_path,e->stderr_path_size,
+		 MYF(MY_NABP)) ||
+	my_write(to_launcher_pipe[1],e->data_buf,e->data_buf_size,
+		 MYF(MY_NABP)))
     {
       e->error="Failed write request to launcher";
       return 1;
@@ -724,6 +810,14 @@
     p=int10_to_str(e->con_port,p,10);
   }
   *p++='\t';
+  p=arg_strmov(p,e->stdout_path,(int)(buf_end-p)-1);
+  if (p==buf_end-1)
+    goto end;
+  *p++='\t';
+  p=arg_strmov(p,e->stderr_path,(int)(buf_end-p)-1);
+  if (p==buf_end-1)
+    goto end;
+  *p++='\t';
   
   for(;p<buf_end && *args;args++)
   {
@@ -1341,7 +1435,8 @@
   num_args=tokenize_args(arg_start,&arg_end);
   arg_len=(uint)(arg_end-arg_start)+1; /* include \0 terminator*/
   if (!(tmp=(struct manager_exec*)my_malloc(sizeof(*tmp)+arg_len+
-					    sizeof(char*)*num_args,MYF(0))))
+					    sizeof(char*)*num_args,
+					    MYF(MY_ZEROFILL))))
     return 0;
   if (num_args<2)
   {
@@ -1350,7 +1445,7 @@
   }
   tmp->data_buf=(char*)tmp+sizeof(*tmp);
   memcpy(tmp->data_buf,arg_start,arg_len);
-  tmp->req_len=arg_len;
+  tmp->data_buf_size=arg_len;
   tmp->args=(char**)(tmp->data_buf+arg_len);
   tmp->num_args=num_args; 
   tmp->ident=tmp->data_buf;
@@ -1358,18 +1453,14 @@
   first_arg=tmp->ident+tmp->ident_len+1;
   init_arg_array(first_arg,tmp->args,num_args-1);
   strmov(tmp->con_user,"root");
-  tmp->con_pass[0]=0;
-  tmp->con_sock[0]=0;
   tmp->con_port=MYSQL_PORT;
   memcpy(tmp->con_host,"localhost",10);
   tmp->bin_path=tmp->args[0];
-  tmp->pid=0;
-  tmp->exit_code=0;
-  tmp->th=0;
+  tmp->stdout_path_size=tmp->stderr_path_size=1;
+  tmp->req_len=tmp->data_buf_size+2;
   pthread_mutex_init(&tmp->lock,0);
   pthread_cond_init(&tmp->cond,0);
   mysql_init(&tmp->mysql);
-  tmp->error=0;
   return tmp;
 }
 
@@ -1480,6 +1571,23 @@
   signal(SIGPIPE,handle_sigpipe);
 }
 
+static int open_and_dup(int fd,char* path)
+{
+  int old_fd;
+  if ((old_fd=my_open(path,O_WRONLY|O_APPEND|O_CREAT,MYF(0)))<0)
+  {
+    log_err("Could not open '%s' for append, errno=%d",path,errno);
+    return 1;
+  }
+  if (dup2(old_fd,fd)<0)
+  {
+    log_err("Failed in dup2(), errno=%d",errno);
+    return 1;
+  }
+  my_close(old_fd,MYF(0));
+  return 0;
+}
+
 static void run_launcher_loop()
 {
   for (;;)
@@ -1487,14 +1595,17 @@
     int req_len,ident_len,num_args;
     char* request_buf=0;
     pid_t pid;
-    char* exec_path,*ident;
+    char* exec_path,*ident,*stdout_path,*stderr_path;
     char** args=0;
     
-    if (read(to_launcher_pipe[0],&req_len,sizeof(int))!=sizeof(int) ||
-	read(to_launcher_pipe[0],&num_args,sizeof(int))!=sizeof(int) ||
+    if (my_read(to_launcher_pipe[0],(byte*)&req_len,
+		sizeof(int),MYF(MY_NABP|MY_FULL_IO)) ||
+	my_read(to_launcher_pipe[0],(byte*)&num_args,
+		sizeof(int),MYF(MY_NABP|MY_FULL_IO)) ||
 	!(request_buf=(char*)my_malloc(req_len+sizeof(pid)+2,MYF(0))) ||
 	!(args=(char**)my_malloc(num_args*sizeof(char*),MYF(0))) ||
-	read(to_launcher_pipe[0],request_buf+1,req_len)!=req_len)
+	my_read(to_launcher_pipe[0],request_buf,req_len,
+		MYF(MY_NABP|MY_FULL_IO)))
     {
       log_err("launcher: Error reading request");
       my_free((gptr)request_buf,MYF(MY_ALLOW_ZERO_PTR));
@@ -1502,12 +1613,16 @@
       sleep(1);
       continue;
     }
+    stdout_path=request_buf;
+    stderr_path=stdout_path+strlen(stdout_path)+1;
+    request_buf=stderr_path+strlen(stderr_path); /* black magic */
     ident=request_buf+1;
     ident_len=strlen(ident);
     exec_path=ident+ident_len+1;
-    log_debug("num_args=%d,req_len=%d,ident=%s,ident_len=%d,exec_path=%s",
+    log_debug("num_args=%d,req_len=%d,ident=%s,ident_len=%d,exec_path=%s,\
+stdout_path=%s,stderr_path=%s",
 	      num_args,
-	      req_len,ident,ident_len,exec_path);
+	      req_len,ident,ident_len,exec_path,stdout_path,stderr_path);
     init_arg_array(exec_path,args,num_args-1);    
         
     switch ((pid=fork()))
@@ -1517,6 +1632,8 @@
       sleep(1);
       break;
     case 0:
+      if (open_and_dup(1,stdout_path) || open_and_dup(2,stderr_path))
+	exit(1);
       if (execv(exec_path,args))
 	log_err("launcher: cannot exec %s",exec_path);
       exit(1);
@@ -1527,7 +1644,7 @@
 	log_err("launcher: error sending launch status report");
       break;
     }
-    my_free((gptr)request_buf,MYF(0));
+    my_free((gptr)(stdout_path),MYF(0));
     my_free((gptr)args,MYF(0));
   }
 }
Thread
bk commit into 4.0 treesasha23 Sep