You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Paul Burba <pt...@gmail.com> on 2008/07/17 19:10:46 UTC

[RFC] Remove AS400 code from trunk (Was: [PATCH] allow pre-lock hook to specify token for locking)

2008/7/16 Chia-liang Kao <cl...@clkao.org>:
> (This is only a preliminary patch)
>
> The patch enabling the pre-lock hook to decide the lock_token to be
> used in the lock operation, which is usually autogenerated.  The
> changes are mostly in run_hook_cmd, making it to optionally take
> stdout and return it as a string.
> The function is basically reimplemented for AS400 though, so I'd
> appreciate helps for making the relevant code changes in the other
> part of the #ifdef... (I was also wondering why such abstraction
> didn't happen in svn_io_start_cmd level though)

As clkao and I just discussed on IRC, the AS400 port has not been
actively maintained since Jan 2007 and AFAIK nobody has any plans to
do so.  So I'm +1 for removing the AS400 implementation of
run_hook_cmd.

Further, I'd like to make a sweep of trunk and remove all AS400
specific code.  If anyone ever takes up the port again it's still all
there, the beauty of version control and all :-)

Any objections?

Paul

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: [RFC] Remove AS400 code from trunk (Was: [PATCH] allow pre-lock hook to specify token for locking)

Posted by Paul Burba <pt...@gmail.com>.
On Thu, Jul 17, 2008 at 3:10 PM, Paul Burba <pt...@gmail.com> wrote:
> 2008/7/16 Chia-liang Kao <cl...@clkao.org>:
>> (This is only a preliminary patch)
>>
>> The patch enabling the pre-lock hook to decide the lock_token to be
>> used in the lock operation, which is usually autogenerated.  The
>> changes are mostly in run_hook_cmd, making it to optionally take
>> stdout and return it as a string.
>> The function is basically reimplemented for AS400 though, so I'd
>> appreciate helps for making the relevant code changes in the other
>> part of the #ifdef... (I was also wondering why such abstraction
>> didn't happen in svn_io_start_cmd level though)
>
> As clkao and I just discussed on IRC, the AS400 port has not been
> actively maintained since Jan 2007 and AFAIK nobody has any plans to
> do so.  So I'm +1 for removing the AS400 implementation of
> run_hook_cmd.
>
> Further, I'd like to make a sweep of trunk and remove all AS400
> specific code.  If anyone ever takes up the port again it's still all
> there, the beauty of version control and all :-)
>
> Any objections?

Done r32364.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: [RFC] Remove AS400 code from trunk (Was: [PATCH] allow pre-lock hook to specify token for locking)

Posted by Chia-liang Kao <cl...@clkao.org>.
Attached is the patch removing the bits in hook.c.

> > > The patch enabling the pre-lock hook to decide the lock_token to be
> > > used in the lock operation, which is usually autogenerated.  The
> > > changes are mostly in run_hook_cmd, making it to optionally take
> > > stdout and return it as a string.
> > > The function is basically reimplemented for AS400 though, so I'd
> > > appreciate helps for making the relevant code changes in the other
> > > part of the #ifdef... (I was also wondering why such abstraction
> > > didn't happen in svn_io_start_cmd level though)
> > 
> > As clkao and I just discussed on IRC, the AS400 port has not been
> > actively maintained since Jan 2007 and AFAIK nobody has any plans to
> > do so.  So I'm +1 for removing the AS400 implementation of
> > run_hook_cmd.
> > 
> > Further, I'd like to make a sweep of trunk and remove all AS400
> > specific code.  If anyone ever takes up the port again it's still all
> > there, the beauty of version control and all 
> > 
> > Any objections?
> 
> +1
> 


[[[
Remove code in AS400 #ifdef from libsvn_repos/hook.c, as they are
dead code in trunk.

* subversion/libsvn_repos/hook.c
  Remove #include for AS400 #ifdef.
  (run_hook_cmd): Remove AS400 #ifdef and the code in it.

Approved by: pburba
]]]

=== subversion/libsvn_repos/hooks.c
==================================================================
--- subversion/libsvn_repos/hooks.c	(revision 32149)
+++ subversion/libsvn_repos/hooks.c	(local)
@@ -22,12 +22,6 @@
 #include <apr_pools.h>
 #include <apr_file_io.h>
 
-#ifdef AS400
-#include <apr_portable.h>
-#include <spawn.h>
-#include <fcntl.h>
-#endif
-
 #include "svn_error.h"
 #include "svn_path.h"
 #include "svn_repos.h"
@@ -39,23 +33,6 @@
 
 /*** Hook drivers. ***/
 
-#ifndef AS400
-/* Helper function for run_hook_cmd().  Wait for a hook to finish
-   executing and return either SVN_NO_ERROR if the hook script completed
-   without error, or an error describing the reason for failure.
-
-   NAME and CMD are the name and path of the hook program, CMD_PROC
-   is a pointer to the structure representing the running process,
-   and READ_ERRHANDLE is an open handle to the hook's stderr.
-
-   Hooks are considered to have failed if we are unable to wait for the
-   process, if we are unable to read from the hook's stderr, if the
-   process has failed to exit cleanly (due to a coredump, for example),
-   or if the process returned a non-zero return code.
-
-   Any error output returned by the hook's stderr will be included in an
-   error message, though the presence of output on stderr is not itself
-   a reason to fail a hook. */
 static svn_error_t *
 check_hook_result(const char *name, const char *cmd, apr_proc_t *cmd_proc,
                   apr_file_t *read_errhandle, apr_pool_t *pool)
@@ -156,7 +133,6 @@
   return svn_error_create(SVN_ERR_REPOS_HOOK_FAILURE, err,
                           failure_message->data);
 }
-#endif /* AS400 */
 
 /* NAME, CMD and ARGS are the name, path to and arguments for the hook
    program that is to be run.  The hook's exit status will be checked,
@@ -171,7 +147,6 @@
              const char **args,
              apr_file_t *stdin_handle,
              apr_pool_t *pool)
-#ifndef AS400
 {
   apr_file_t *read_errhandle, *write_errhandle, *null_handle;
   apr_status_t apr_err;
@@ -247,224 +222,8 @@
 
   return err;
 }
-#else /* Run hooks with spawn() on OS400. */
-#define AS400_BUFFER_SIZE 256
-{
-  const char **native_args;
-  int fd_map[3], stderr_pipe[2], exitcode;
-  svn_stringbuf_t *script_output;
-  pid_t child_pid, wait_rv;
-  apr_size_t args_arr_size = 0, i;
-  struct inheritance xmp_inherit = {0};
-#pragma convert(0)
-  /* Despite the UTF support in V5R4 a few functions still require
-   * EBCDIC args. */
-  char *xmp_envp[2] = {"QIBM_USE_DESCRIPTOR_STDIO=Y", NULL};
-  const char *dev_null_ebcdic = SVN_NULL_DEVICE_NAME;
-#pragma convert(1208)
 
-  /* Find number of elements in args array. */
-  while (args[args_arr_size] != NULL)
-    args_arr_size++;
 
-  /* Allocate memory for the native_args string array plus one for
-   * the ending null element. */
-  native_args = apr_palloc(pool, sizeof(char *) * args_arr_size + 1);
-
-  /* Convert UTF-8 args to EBCDIC for use by spawn(). */
-  for (i = 0; args[i] != NULL; i++)
-    {
-      SVN_ERR(svn_utf_cstring_from_utf8_ex2((const char**)(&(native_args[i])),
-                                            args[i], (const char *)0,
-                                            pool));
-    }
-
-  /* Make the last element in the array a NULL pointer as required
-   * by spawn. */
-  native_args[args_arr_size] = NULL;
-
-  /* Map stdin. */
-  if (stdin_handle)
-    {
-      /* Get OS400 file descriptor of APR stdin file and map it. */
-      if (apr_os_file_get(&fd_map[0], stdin_handle))
-        {
-          return svn_error_createf(SVN_ERR_REPOS_HOOK_FAILURE, NULL,
-                                   "Error converting APR file to OS400 "
-                                   "type for hook script '%s'", cmd);
-        }
-    }
-  else
-    {
-      fd_map[0] = open(dev_null_ebcdic, O_RDONLY);
-      if (fd_map[0] == -1)
-
-        return svn_error_createf(SVN_ERR_REPOS_HOOK_FAILURE, NULL,
-                                 "Error opening /dev/null for hook "
-                                 "script '%s'", cmd);
-    }
-
-
-  /* Map stdout. */
-  fd_map[1] = open(dev_null_ebcdic, O_WRONLY);
-  if (fd_map[1] == -1)
-    return svn_error_createf(SVN_ERR_REPOS_HOOK_FAILURE, NULL,
-                             "Error opening /dev/null for hook script '%s'",
-                             cmd);
-
-  /* Map stderr. */
-  /* Get pipe for hook's stderr. */
-  if (pipe(stderr_pipe) != 0)
-    {
-      return svn_error_createf(SVN_ERR_REPOS_HOOK_FAILURE, NULL,
-                               "Can't create stderr pipe for "
-                               "hook '%s'", cmd);
-    }
-  fd_map[2] = stderr_pipe[1];
-
-  /* Spawn the hook command. */
-  child_pid = spawn(native_args[0], 3, fd_map, &xmp_inherit, native_args,
-                    xmp_envp);
-  if (child_pid == -1)
-    {
-      return svn_error_createf(SVN_ERR_REPOS_HOOK_FAILURE, NULL,
-                               "Error spawning process for hook script '%s'",
-                               cmd);
-    }
-
-  /* Close the stdout file descriptor. */
-  if (close(fd_map[1]) == -1)
-    return svn_error_createf(SVN_ERR_REPOS_HOOK_FAILURE, NULL,
-                             "Error closing write end of stdout pipe to "
-                             "hook script '%s'", cmd);
-
-  /* Close the write end of the stderr pipe so any subsequent reads
-   * don't hang. */
-  if (close(fd_map[2]) == -1)
-    return svn_error_createf(SVN_ERR_REPOS_HOOK_FAILURE, NULL,
-                             "Error closing write end of stderr pipe to "
-                             "hook script '%s'", cmd);
-
-  script_output = svn_stringbuf_create("", pool);
-
-  while (1)
-    {
-      int rc;
-
-      svn_stringbuf_ensure(script_output,
-                           script_output->len + AS400_BUFFER_SIZE + 1);
-
-      rc = read(stderr_pipe[0],
-                &(script_output->data[script_output->len]),
-                AS400_BUFFER_SIZE);
-
-      if (rc == -1)
-        {
-          return svn_error_createf(SVN_ERR_REPOS_HOOK_FAILURE, NULL,
-                                   "Error reading stderr of hook "
-                                   "script '%s'", cmd);
-        }
-
-      script_output->len += rc;
-
-      /* If read() returned 0 then EOF was found and we are done reading
-       * stderr. */
-      if (rc == 0)
-        {
-          script_output->data[script_output->len] = '\0';
-          break;
-        }
-    }
-
-  /* Close the read end of the stderr pipe. */
-  if (close(stderr_pipe[0]) == -1)
-    return svn_error_createf(SVN_ERR_REPOS_HOOK_FAILURE, NULL,
-                             "Error closing read end of stderr "
-                             "pipe to hook script '%s'", cmd);
-
-  /* Wait for the child process to complete. */
-  wait_rv = waitpid(child_pid, &exitcode, 0);
-  if (wait_rv == -1)
-    {
-      return svn_error_createf(SVN_ERR_REPOS_HOOK_FAILURE, NULL,
-                               "Error waiting for process completion of "
-                               "hook script '%s'", cmd);
-    }
-
-
-  if (WIFEXITED(exitcode))
-    {
-      if (WEXITSTATUS(exitcode))
-        {
-          svn_error_t *err;
-          const char *utf8_stderr = NULL;
-          svn_stringbuf_t *failure_message = svn_stringbuf_createf(
-            pool, "'%s' hook failed (exited with a non-zero exitcode "
-            "of %d).  ", name, exitcode);
-
-          if (!svn_stringbuf_isempty(script_output))
-            {
-              /* OS400 scripts produce EBCDIC stderr, so convert it. */
-              err = svn_utf_cstring_to_utf8_ex2(&utf8_stderr,
-                                                script_output->data,
-                                                (const char*)0, pool);
-              if (err)
-                {
-                  utf8_stderr = "[Error output could not be translated from "
-                                "the native locale to UTF-8.]";
-                  svn_error_clear(err);
-
-                }
-            }
-
-          if (utf8_stderr)
-            {
-              svn_stringbuf_appendcstr(failure_message,
-                                       "The following error output was "
-                                       "produced by the hook:\n");
-              svn_stringbuf_appendcstr(failure_message, utf8_stderr);
-            }
-          else
-            {
-              svn_stringbuf_appendcstr(failure_message,
-                                       "No error output was produced by "
-                                       "the hook.");
-            }
-          return svn_error_create(SVN_ERR_REPOS_HOOK_FAILURE, NULL,
-                                  failure_message->data);
-        }
-      else
-        /* Success! */
-        return SVN_NO_ERROR;
-    }
-  else if (WIFSIGNALED(exitcode))
-    {
-      return svn_error_createf(SVN_ERR_REPOS_HOOK_FAILURE, NULL,
-                               "Process '%s' failed because of an "
-                               "uncaught terminating signal", cmd);
-    }
-  else if (WIFEXCEPTION(exitcode))
-    {
-      return svn_error_createf(SVN_ERR_REPOS_HOOK_FAILURE, NULL,
-                               "Process '%s' failed unexpectedly with "
-                               "OS400 exception %d", cmd,
-                               WEXCEPTNUMBER(exitcode));
-    }
-  else if (WIFSTOPPED(exitcode))
-    {
-      return svn_error_createf(SVN_ERR_REPOS_HOOK_FAILURE, NULL,
-                               "Process '%s' stopped unexpectedly by "
-                               "signal %d", cmd, WSTOPSIG(exitcode));
-    }
-  else
-    {
-      return svn_error_createf(SVN_ERR_REPOS_HOOK_FAILURE, NULL,
-                               "Process '%s' failed unexpectedly", cmd);
-    }
-}
-#endif /* AS400 */
-
-
 /* Create a temporary file F that will automatically be deleted when it is
    closed.  Fill it with VALUE, and leave it open and rewound, ready to be
    read from. */



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: [RFC] Remove AS400 code from trunk (Was: [PATCH] allow pre-lock hook to specify token for locking)

Posted by Arfrever Frehtes Taifersar Arahesis <ar...@gmail.com>.
2008-07-17 21:10:46 Paul Burba napisaƂ(a):
> 2008/7/16 Chia-liang Kao <cl...@clkao.org>:
> > (This is only a preliminary patch)
> >
> > The patch enabling the pre-lock hook to decide the lock_token to be
> > used in the lock operation, which is usually autogenerated.  The
> > changes are mostly in run_hook_cmd, making it to optionally take
> > stdout and return it as a string.
> > The function is basically reimplemented for AS400 though, so I'd
> > appreciate helps for making the relevant code changes in the other
> > part of the #ifdef... (I was also wondering why such abstraction
> > didn't happen in svn_io_start_cmd level though)
> 
> As clkao and I just discussed on IRC, the AS400 port has not been
> actively maintained since Jan 2007 and AFAIK nobody has any plans to
> do so.  So I'm +1 for removing the AS400 implementation of
> run_hook_cmd.
> 
> Further, I'd like to make a sweep of trunk and remove all AS400
> specific code.  If anyone ever takes up the port again it's still all
> there, the beauty of version control and all :-)
> 
> Any objections?

+1

-- 
Arfrever Frehtes Taifersar Arahesis

Re: [RFC] Remove AS400 code from trunk (Was: [PATCH] allow pre-lock hook to specify token for locking)

Posted by Mark Phippard <ma...@gmail.com>.
On Thu, Jul 17, 2008 at 3:10 PM, Paul Burba <pt...@gmail.com> wrote:
> 2008/7/16 Chia-liang Kao <cl...@clkao.org>:
>> (This is only a preliminary patch)
>>
>> The patch enabling the pre-lock hook to decide the lock_token to be
>> used in the lock operation, which is usually autogenerated.  The
>> changes are mostly in run_hook_cmd, making it to optionally take
>> stdout and return it as a string.
>> The function is basically reimplemented for AS400 though, so I'd
>> appreciate helps for making the relevant code changes in the other
>> part of the #ifdef... (I was also wondering why such abstraction
>> didn't happen in svn_io_start_cmd level though)
>
> As clkao and I just discussed on IRC, the AS400 port has not been
> actively maintained since Jan 2007 and AFAIK nobody has any plans to
> do so.  So I'm +1 for removing the AS400 implementation of
> run_hook_cmd.
>
> Further, I'd like to make a sweep of trunk and remove all AS400
> specific code.  If anyone ever takes up the port again it's still all
> there, the beauty of version control and all :-)
>
> Any objections?

+1

No one is maintaining the code and as you said, it can always be resurrected.

-- 
Thanks

Mark Phippard
http://markphip.blogspot.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org