[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Gridengine unblock



Hi,

I'd like to request an unblock for gridengine-6.2-1 with an appropriate
age-days to be set (say 25).

Rationale for allowing new upstream version in:  We currently have
6.2~beta2 in lenny and 6.2 final in unstable.  I deliberately allowed
6.2~beta2 to enter lenny before the freeze in order to make sure that it
had entered testing.  My aim was, however, to ship 6.2 final.
Unfortunately, this wasn't released before the freeze.  Given the nature
of the SGE software, it is likely that some security vulnerabilities
will be found during the lifetime of lenny and it will make my life much
easier to backport the fixes to the 6.2 main release than to a beta
release.  There have also been some major bugfixes since the beta and,
in the part of the code which debian uses, no enhancements have been
made (except in one unit test)

The overall diffstat is:

 171 files changed, 7274 insertions(+), 5585 deletions(-)

However, much of this diff is ignorable (doc changes, files only used on
non-debian arches, install scripts never used by debian and java based
stuff [the current SGE pacakges don't support any of the java features
in SGE as openjdk entered main too late]).  The remaining diffstat is:

 87 files changed, 2169 insertions(+), 1306 deletions(-)

which corresponds to the following bug fixes relevant to Debian:

RN-2008-07-22-0: Bugfix: qmaster crashes while project deletion (qconf -dprj) in a special case Bugster: 6728262 Issue: 2672 Review: JG Issue number: 
MP-2008-07-19-0: Bugfix: Fixed spelling mistakes in the man pages.
AH-2008-07-18-0: Bugfix: Fixed error that caused tight_integration_massive test to fail. Bugster: 6710983 Issue: 2603 Review: CR Belongs to: AH-2008-06-10-0 Issue number: 
AA-2008-07-18-0: Bugfix: o qconf invalid values and exit code fixes Bugster: 6618016, 6618012, 6617973 Issue: 2662 Review: MD
JG-2008-07-14-0: Bugfix: Fixed minor memory leaks. Bugster: 6724877 Issue: 2650 Review: HP Issue number: 
EB-2008-07-17-0: Bugfix: Qmaster message file contains logging about NULL ptr passed to host_list_locate() Bugster: 6726283 Issue: 2658 Review: JG
HP-2008-07-16-0: Bugfix: Using fix HP-2008-07-14-0 for all architectures now Cleanup to: HP-2008-07-14-0 Review: CR
DG-2008-07-16-0: Bugfix: qsub -w v always returns success. Bugster: 6724949 Issue: 2652 Review: JG
MP-2008-07-14-0: Bugfix: Merged from V61_BRANCH: MP-2008-7-11-0 Bugster: 6716082 Issue: 2644 Review: JG
JG-2008-07-14-0: Bugfix: Fixed minor memory leaks. Bugster: 6724877 Issue: 2650 Review: EB, HP, CR Issue number: 
HP-2008-07-14-0: Bugfix: Fixed wrongly set signals in commlib threads Bugster: 6725446 Issue: 2653 Review: EB, CR
RN-2008-07-14-0: Bugfix: 'Infinity' must be rejected when specified in 'complex_values' or RQS limits for consumables Bugster: 6613438 Issue: 2391 Review: AH Issue number: 
CR-2008-07-11-0: Bugfix: - Merged from V61_BRANCH: CR-2008-07-09-0 - Execd Cleanup Review: MD
HP-2008-07-11-0: Bugfix: Added workaround to set missing resource limits Bugster: 6722507, 6533487 Issue: 2370 Review: AS, MD
JG-2008-07-11-0: Bugfix: Fixed minor memory leaks. Bugster: 6724877 Issue: 2650 Review: MD Issue number: 
JA-2008-07-11-1: Bugfix: - improve precondition in sge_task_depend_get_range to accept any valid task id - remove warnings and debug messages associated with sge_task_depend_get_range failure Review: AH,JG
JA-2008-07-11-0: Bugfix: Tasks held with array dependency may get deleted prematurely Bugster: 6723951 Issue: 2628 Review: AH
JG-2008-07-10-0: Bugfix: Error message of qalter -q "" <job_id> suggests memory corruption. Bugster: 6704393 Issue: 2575 Review: MD Issue number: 
MP-2008-07-08-0: Enhancem: Updated the test_flatfile_spool file to take into account parsing of RQSes with a backslash followed by a line break combination Review: RD
RD-2008-08-08-1: Cleanup: - removed references to DRMAA 0.95 from man pages - deprecated obsolete parameters/switches - removed redundant upgrade documents Review: AA
RD-2008-08-08-0: Cleanup: - fixed and enhanced test_performance module test - some smaller code cleanups Review: AA
MP-2008-07-07-0: Bugfix: RQS: Line wrap of host list introduces syntax error Bugster: 6647676 Issue: 2449 Review: DT
JG-2008-07-04-0: Bugfix: Same path for input and output/error file must be rejected. Bugster: 6310194 Issue: 1751 Review: RD Issue number: 
AH-2008-07-03-1: Bugfix: Invalid qconf -mrqs crashes qmaster with segmentation fault Bugster: 6722217 Issue: 2432 Review: TH,RD Issue number: 
MP-2008-07-02-0: Bugfix: qstat -j does not print array task information Bugster: 6710485 Issue: 2606 Review: JG
HP-2008-07-02-0: Bugfix: shepherd wasn't able to read user certificates Bugster: 6718433 Bugfix: insufficient handling of commlib errors Bugster: 6718447 Bugfix: incorrect accounting when terminate method is used Bugster: 6718453 Bugfix: qrsh and qlogin has very slow response to user input Bugster: 6686921 Review: JG
AA-2008-06-19-0: Bugfix: sge_ca script does not allow easy sdm_admin keystore creation Bugster: 6716648 Issue: 2619 Review: RH
JG-2008-06-16-0: Bugfix: reporting file is lacking information about global consumables, if log_consumables=false Bugster: 6710542 Issue: 2615 Review: HP Issue number: 
AH-2008-06-12-0 Bugfix: - qalter -w v is silent on finished jobs - qalter -w v wrongly changes job attributes Bugster: 6708891,6712685 Issue: 2598,2607 Review: RD Issue number: 
RD-2008-06-12-1: Bugfix: fixed possible segfault introduced with RD-2008-06-12-0 Review: DG 
RD-2008-06-12-0: Bugfix: load_sensor does not work with reports for other hosts Bugster: 6713785 Issue: 2611 Review: DG

Attached is the actual diff corresponding to the debian-relevant changes.

Thanks,

Mark

-- 
Mark Hymers <mhy at debian dot org>

"The first thing we do, let's kill all the Lawyers"
     Henry VI Part II, Shakespeare
diff --exclude-from=/srv/pbuilder/result/sid/sge_ignore -Naur gridengine-6.2~beta2/source/clients/common/sge_client_ijs.c gridengine-6.2/source/clients/common/sge_client_ijs.c
--- gridengine-6.2~beta2/source/clients/common/sge_client_ijs.c	2008-06-15 15:29:36.000000000 +0100
+++ gridengine-6.2/source/clients/common/sge_client_ijs.c	2008-08-08 18:14:02.000000000 +0100
@@ -182,6 +182,8 @@
 *******************************************************************************/
 void set_signal_handlers(void)
 {
+  struct sigaction old_handler, new_handler;
+
    /* Is SIGHUP necessary? 
     * Yes: termio(7I) says:
     * "When a modem disconnect is detected, a SIGHUP signal is sent
@@ -191,20 +193,47 @@
     *  caught, any subsequent  read  returns  with  an  end-of-file
     *  indication until the terminal is closed."
     */
-   if (signal(SIGHUP, SIG_IGN) != SIG_IGN) {
-      sigset(SIGHUP, signal_handler);
-   }
-   if (signal(SIGINT, SIG_IGN) != SIG_IGN) {
-      sigset(SIGINT, signal_handler);
-   }
-   if (signal(SIGQUIT, SIG_IGN) != SIG_IGN) {
-      sigset(SIGQUIT, signal_handler);
-   }
-   if (signal(SIGTERM, SIG_IGN) != SIG_IGN) {
-      sigset(SIGTERM, signal_handler);
-   }
-   sigset(SIGWINCH, window_change_handler);
-   sigset(SIGPIPE,  broken_pipe_handler);
+   sigaction(SIGHUP, NULL, &old_handler);
+   if (old_handler.sa_handler != SIG_IGN) {
+      new_handler.sa_handler = signal_handler;
+      sigaddset(&new_handler.sa_mask, SIGHUP);
+      new_handler.sa_flags = SA_RESTART;
+      sigaction(SIGHUP, &new_handler, NULL);
+   }
+
+   sigaction(SIGINT, NULL, &old_handler);
+   if (old_handler.sa_handler != SIG_IGN) {
+      new_handler.sa_handler = signal_handler;
+      sigaddset(&new_handler.sa_mask, SIGINT);
+      new_handler.sa_flags = SA_RESTART;
+      sigaction(SIGINT, &new_handler, NULL);
+   }
+
+   sigaction(SIGQUIT, NULL, &old_handler);
+   if (old_handler.sa_handler != SIG_IGN) {
+      new_handler.sa_handler = signal_handler;
+      sigaddset(&new_handler.sa_mask, SIGQUIT);
+      new_handler.sa_flags = SA_RESTART;
+      sigaction(SIGQUIT, &new_handler, NULL);
+   }
+
+   sigaction(SIGTERM, NULL, &old_handler);
+   if (old_handler.sa_handler != SIG_IGN) {
+      new_handler.sa_handler = signal_handler;
+      sigaddset(&new_handler.sa_mask, SIGTERM);
+      new_handler.sa_flags = SA_RESTART;
+      sigaction(SIGTERM, &new_handler, NULL);
+   }
+
+   new_handler.sa_handler = window_change_handler;
+   sigaddset(&new_handler.sa_mask, SIGWINCH);
+   new_handler.sa_flags = SA_RESTART;
+   sigaction(SIGWINCH, &new_handler, NULL);
+
+   new_handler.sa_handler = broken_pipe_handler;
+   sigaddset(&new_handler.sa_mask, SIGPIPE);
+   new_handler.sa_flags = SA_RESTART;
+   sigaction(SIGPIPE, &new_handler, NULL);
 }
 
 /****** client_check_window_change() *******************************************
@@ -428,13 +457,8 @@
       recv_mess.cl_message = NULL;
       recv_mess.data = NULL;
 
-      DPRINTF(("commlib_to_tty: Waiting in comm_trigger() for data\n"));
-      ret = comm_trigger(g_comm_handle, 1, &err_msg);
-      DPRINTF(("commlib_to_tty: comm_trigger() returned %d, %s\n",
-              ret, &err_msg));
-
       DPRINTF(("commlib_to_tty: recv_message()\n"));
-      ret = comm_recv_message(g_comm_handle, CL_FALSE, &recv_mess, &err_msg);
+      ret = comm_recv_message(g_comm_handle, CL_TRUE, &recv_mess, &err_msg);
       if (ret != COMM_RETVAL_OK) {
          /* check if we are still connected to anybody. */
          /* if not - exit. */
@@ -456,6 +480,8 @@
           received_signal == SIGQUIT ||
           received_signal == SIGTERM) {
          /* If we receive one of these signals, we must terminate */
+         DPRINTF(("commlib_to_tty: shutting down because of signal %d\n",
+                 received_signal));
          do_exit = 1;
          continue;
       }
@@ -471,8 +497,8 @@
          switch (recv_mess.type) {
             case STDOUT_DATA_MSG:
                /* copy recv_mess.data to buf to append '\0' */
-               snprintf(buf, MIN(100, recv_mess.cl_message->message_length),
-                        "%s", recv_mess.data);
+               memcpy(buf, recv_mess.data, MIN(99, recv_mess.cl_message->message_length - 1));
+               buf[MIN(99, recv_mess.cl_message->message_length - 1)] = 0;
                DPRINTF(("commlib_to_tty: received stdout message, writing to tty.\n"));
                DPRINTF(("commlib_to_tty: message is: %s\n", buf));
 /* TODO: If it's not possible to write all data to the tty, retry blocking
@@ -526,8 +552,8 @@
                DPRINTF(("commlib_to_tty: writing UNREGISTER_RESPONSE_CTRL_MSG\n"));
 
                /* copy recv_mess.data to buf to append '\0' */
-               snprintf(buf, MIN(100, recv_mess.cl_message->message_length),
-                        "%s", recv_mess.data);
+               memcpy(buf, recv_mess.data, MIN(99, recv_mess.cl_message->message_length - 1));
+               buf[MIN(99, recv_mess.cl_message->message_length - 1)] = 0;
                sscanf(buf, "%d", &g_exit_status);
                comm_write_message(g_comm_handle, g_hostname, COMM_CLIENT, 1, 
                   (unsigned char*)" ", 1, UNREGISTER_RESPONSE_CTRL_MSG, &err_msg);
@@ -553,7 +579,9 @@
 *     do_server_loop() -- The servers main loop
 *
 *  SYNOPSIS
-*     void* commlib_to_tty(void *t_conf)
+*     int do_server_loop(u_long32 job_id, int nostdin, int noshell,
+*                        int is_rsh, int is_qlogin, int force_pty,
+*                        int *p_exit_status)
 *
 *  FUNCTION
 *     The main loop of the commlib server, handling the data transfer from
@@ -663,6 +691,7 @@
 */
    DPRINTF(("shut down the connection from our side\n"));
    comm_shutdown_connection(g_comm_handle, COMM_CLIENT, &err_msg);
+   g_comm_handle = NULL;
    /*
     * Close stdin to awake the tty_to_commlib-thread from the select() call.
     * thread_shutdown() doesn't work on all architectures.
@@ -671,7 +700,6 @@
 
    DPRINTF(("waiting for end of tty_to_commlib thread\n"));
    thread_join(pthread_tty_to_commlib);
-   thread_cleanup_lib(&thread_lib_handle);
 cleanup:
    /*
     * Set our terminal back to 'unraw' mode. Should be done automatically
@@ -685,6 +713,8 @@
    }
 
    *p_exit_status = g_exit_status;
+
+   thread_cleanup_lib(&thread_lib_handle);
    DEXIT;
    return 0;
 }
diff --exclude-from=/srv/pbuilder/result/sid/sge_ignore -Naur gridengine-6.2~beta2/source/clients/common/sge_client_ijs.h gridengine-6.2/source/clients/common/sge_client_ijs.h
--- gridengine-6.2~beta2/source/clients/common/sge_client_ijs.h	2008-06-15 15:29:36.000000000 +0100
+++ gridengine-6.2/source/clients/common/sge_client_ijs.h	2008-08-08 18:14:02.000000000 +0100
@@ -30,8 +30,8 @@
  ************************************************************************/
 /*___INFO__MARK_END__*/
 
-#define COMM_SERVER "qrsh"
-#define COMM_CLIENT "shepherd"
+#define COMM_SERVER "qrsh_ijs"
+#define COMM_CLIENT "shepherd_ijs"
 
 void set_signal_handlers(void);
 void* tty_to_commlib(void *t_conf);
diff --exclude-from=/srv/pbuilder/result/sid/sge_ignore -Naur gridengine-6.2~beta2/source/clients/common/sge_hgroup_qconf.c gridengine-6.2/source/clients/common/sge_hgroup_qconf.c
--- gridengine-6.2~beta2/source/clients/common/sge_hgroup_qconf.c	2008-06-15 15:29:36.000000000 +0100
+++ gridengine-6.2/source/clients/common/sge_hgroup_qconf.c	2008-08-08 18:14:01.000000000 +0100
@@ -198,9 +198,10 @@
                                        hgroup, false) || 
                 ignore_unchanged_message) {
                lFreeElem(this_elem);
-               *this_elem = hgroup; 
+               *this_elem = hgroup;
                ret = true;
             } else {
+               lFreeElem(&hgroup);
                answer_list_add(answer_list, MSG_FILE_NOTCHANGED,
                                STATUS_ERROR1, ANSWER_QUALITY_ERROR);
             }
diff --exclude-from=/srv/pbuilder/result/sid/sge_ignore -Naur gridengine-6.2~beta2/source/clients/common/sge_qstat.c gridengine-6.2/source/clients/common/sge_qstat.c
--- gridengine-6.2~beta2/source/clients/common/sge_qstat.c	2008-06-15 15:29:36.000000000 +0100
+++ gridengine-6.2/source/clients/common/sge_qstat.c	2008-08-08 18:14:02.000000000 +0100
@@ -1432,7 +1432,7 @@
 
    summary.resv_slots = qinstance_slots_reserved_now(q);
    summary.used_slots = qinstance_slots_used(q);
-   summary.free_slots = (int)lGetUlong(q, QU_job_slots);
+   summary.total_slots = (int)lGetUlong(q, QU_job_slots);
 
    /* arch */
    if (!sge_get_string_qattr(arch_string, sizeof(arch_string)-1, LOAD_ATTR_ARCH, 
diff --exclude-from=/srv/pbuilder/result/sid/sge_ignore -Naur gridengine-6.2~beta2/source/clients/common/sge_qstat.h gridengine-6.2/source/clients/common/sge_qstat.h
--- gridengine-6.2~beta2/source/clients/common/sge_qstat.h	2008-06-15 15:29:36.000000000 +0100
+++ gridengine-6.2/source/clients/common/sge_qstat.h	2008-08-08 18:14:01.000000000 +0100
@@ -157,7 +157,7 @@
    
    u_long32    used_slots;
    u_long32    resv_slots;
-   u_long32    free_slots;
+   u_long32    total_slots;
    
    const char* arch;
    const char* state;
diff --exclude-from=/srv/pbuilder/result/sid/sge_ignore -Naur gridengine-6.2~beta2/source/clients/qconf/parse_qconf.c gridengine-6.2/source/clients/qconf/parse_qconf.c
--- gridengine-6.2~beta2/source/clients/qconf/parse_qconf.c	2008-06-15 15:29:36.000000000 +0100
+++ gridengine-6.2/source/clients/qconf/parse_qconf.c	2008-08-08 18:14:02.000000000 +0100
@@ -611,8 +611,8 @@
 
          spp = sge_parser_get_next(spp);
          parse_name_list_to_cull("host to add", &lp, AH_Type, AH_name, *spp);
-         if (add_host_of_type(ctx, lp, SGE_ADMINHOST_LIST) != 0) {
-            sge_parse_return = 1;
+         if (!add_host_of_type(ctx, lp, SGE_ADMINHOST_LIST)) {
+            sge_parse_return |= 1;
          }
          
          lFreeList(&lp);
@@ -3550,27 +3550,32 @@
          answer_exit_if_not_recoverable(aep);
          if (answer_get_status(aep) != STATUS_OK) {
             fprintf(stderr, "%s\n", lGetString(aep, AN_text));
+            lFreeList(&alp);
+            lFreeList(&lp);
             sge_parse_return = 1;
             spp++;
             continue;
          }
+         lFreeList(&alp);
 
-         if (!lp || lGetNumberOfElem(lp) == 0) {
+         if (lp == NULL || lGetNumberOfElem(lp) == 0) {
             fprintf(stderr, MSG_USER_XISNOKNOWNUSER_S, *spp);
             fprintf(stderr, "\n");
             spp++;
+            lFreeList(&lp);
             continue;
          }
-         lFreeList(&alp);
          ep = lFirst(lp);
          
          /* edit user */
          newep = edit_user(ep, uid, gid);
 
          /* if the user name has changed, we need to print an error message */   
-         if (strcmp(lGetString(ep, UU_name), lGetString(newep, UU_name))) {
+         if (newep == NULL || strcmp(lGetString(ep, UU_name), lGetString(newep, UU_name))) {
             fprintf(stderr, MSG_QCONF_CANTCHANGEOBJECTNAME_SS, lGetString(ep, UU_name), lGetString(newep, UU_name));
             fprintf(stderr, "\n");
+            lFreeElem(&newep);
+            lFreeList(&lp);
             DRETURN(1);
          } else {
             lFreeList(&lp);
@@ -3617,13 +3622,17 @@
          answer_exit_if_not_recoverable(aep);
          if (answer_get_status(aep) != STATUS_OK) {
             fprintf(stderr, "%s\n", lGetString(aep, AN_text));
+            lFreeList(&alp);
+            lFreeList(&lp);
             spp++;
             continue;
          }
+         lFreeList(&alp);
 
          if (lp == NULL || lGetNumberOfElem(lp) == 0) {
             fprintf(stderr, MSG_PROJECT_XISNOKNWOWNPROJECT_S, *spp);
             fprintf(stderr, "\n");
+            lFreeList(&lp);
             continue;
          }
          lFreeList(&alp);
@@ -5173,7 +5182,9 @@
             sge_error_and_exit(MSG_FILE_NOFILEARGUMENTGIVEN);
          }
          
-         cqueue_add_from_file(ctx, &answer_list, file);
+         if (!cqueue_add_from_file(ctx, &answer_list, file)) {
+            sge_parse_return |= 1;
+         }
          sge_parse_return |= show_answer(answer_list);
          lFreeList(&answer_list);
          
@@ -6516,6 +6527,7 @@
          fprintf(stderr, MSG_ANSWER_CONFIGXNOTDEFINED_S, cfn);
          fprintf(stderr, "\n");
          lFreeList(&alp);
+         lFreeList(&lp);
          DRETURN(1);
       }
       printf("#%s:\n", cfn);
diff --exclude-from=/srv/pbuilder/result/sid/sge_ignore -Naur gridengine-6.2~beta2/source/clients/qdel/qdel.c gridengine-6.2/source/clients/qdel/qdel.c
--- gridengine-6.2~beta2/source/clients/qdel/qdel.c	2008-06-15 15:29:36.000000000 +0100
+++ gridengine-6.2/source/clients/qdel/qdel.c	2008-08-08 18:14:02.000000000 +0100
@@ -73,7 +73,6 @@
    lListElem *aep, *idep;
    lList *jlp = NULL, *alp = NULL, *pcmdline = NULL, *ref_list = NULL, *user_list=NULL;
    u_long32 force = 0;
-   int cmd;
    int wait;
    unsigned long status = 0;
    bool have_master_privileges;
@@ -128,10 +127,6 @@
    handle=cl_com_get_handle(prognames[QDEL], 0);
    cl_com_set_synchron_receive_timeout(handle, 10*60);
 
-   /* prepare gdi request for 'all' and '-uall' parameters */
-   cmd = SGE_GDI_DEL;
-
-
    /* Are there jobs which should be deleted? */
    if (!ref_list) {
       sge_usage(QDEL, stderr);
@@ -215,7 +210,7 @@
                   }   
                }
             }
-            alp = ctx->gdi(ctx, SGE_JOB_LIST, cmd, &part_ref_list, NULL, NULL);
+            alp = ctx->gdi(ctx, SGE_JOB_LIST, SGE_GDI_DEL, &part_ref_list, NULL, NULL);
 
             for_each(aep, alp) {
                status = lGetUlong(aep, AN_status);
diff --exclude-from=/srv/pbuilder/result/sid/sge_ignore -Naur gridengine-6.2~beta2/source/clients/qsh/qsh.c gridengine-6.2/source/clients/qsh/qsh.c
--- gridengine-6.2~beta2/source/clients/qsh/qsh.c	2008-06-15 15:29:36.000000000 +0100
+++ gridengine-6.2/source/clients/qsh/qsh.c	2008-08-08 18:14:02.000000000 +0100
@@ -1695,8 +1695,8 @@
        * start the commlib server
        */
       DPRINTF(("starting commlib server\n"));
-      ret = comm_open_connection(true, 0, COMM_SERVER, g_csp_mode, username,
-                                 &g_comm_handle, &error_msg);
+      ret = comm_open_connection(true, g_csp_mode, COMM_SERVER, 0, COMM_CLIENT,
+                                 username, &g_comm_handle, &error_msg);
 
       if (ret != 0) {
          ERROR((SGE_EVENT, MSG_QSH_CREATINGCOMMLIBSERVER_S,
@@ -1809,7 +1809,7 @@
           * Wait for the client (=shepherd) to connect to us
           */
          DPRINTF(("waiting for connection\n"));
-         ret = comm_wait_for_connection(g_comm_handle, COMM_CLIENT, 
+         ret = comm_wait_for_connection(g_comm_handle, COMM_CLIENT,
                                         QSH_SOCKET_FINAL_TIMEOUT, &host, &err_msg);
          sge_dstring_free(&err_msg);
          if (ret != COMM_RETVAL_OK) {
@@ -1995,6 +1995,8 @@
                DPRINTF(("waiting for connection\n"));
                ret = comm_wait_for_connection(g_comm_handle, COMM_CLIENT, 
                                               random_poll, &host, &err_msg);
+               /* JG: TODO: nothing is done with err_msg?? */
+               sge_dstring_free(&err_msg);
                if (ret != COMM_RETVAL_OK) {
                   if (ret == COMM_GOT_TIMEOUT) {
                      DPRINTF(("got no connection within timeout of %d s\n", random_poll));
@@ -2135,7 +2137,7 @@
             DPRINTF(("polling_interval set to %d\n", polling_interval));
          }
       } /* end of while (1) polling */
-      if (g_new_interactive_job_support == true) {
+      if (g_new_interactive_job_support == true && g_comm_handle != NULL) {
          dstring err_msg = DSTRING_INIT;
          int     ret;
 
@@ -2144,6 +2146,8 @@
             DPRINTF(("comm_shutdown_connection() failed: %s (%d)",
                      sge_dstring_get_string(&err_msg), ret));
          }
+
+         sge_dstring_free(&err_msg);
       }
 
       lFreeList(&lp_jobs);
diff --exclude-from=/srv/pbuilder/result/sid/sge_ignore -Naur gridengine-6.2~beta2/source/clients/qstat/qstat.c gridengine-6.2/source/clients/qstat/qstat.c
--- gridengine-6.2~beta2/source/clients/qstat/qstat.c	2008-06-15 15:29:36.000000000 +0100
+++ gridengine-6.2/source/clients/qstat/qstat.c	2008-08-08 18:14:03.000000000 +0100
@@ -1639,8 +1639,8 @@
 
    printf("%-5.5s ", summary->queue_type); 
 
-   /* number of used/free slots */
-   sprintf(to_print, "%d/%d/%d ", (int)summary->resv_slots, (int)summary->used_slots, (int)summary->free_slots); 
+   /* number of used/total slots */
+   sprintf(to_print, "%d/%d/%d ", (int)summary->resv_slots, (int)summary->used_slots, (int)summary->total_slots); 
    printf("%-14.14s ", to_print);   
 
    /* load avg */
@@ -1956,7 +1956,7 @@
       }
    }
    what = lWhat("%T(%I%I%I%I%I%I%I%I%I%I%I%I%I%I%I->%T%I%I%I%I%I%I->%T%I%I%I%I->%T(%I%I%I%I%I)"
-            "%I%I%I%I->%T(%I)%I->%T(%I)%I%I%I%I%I%I%I%I%I%I%I%I%I%I%I->%T%I%I%I%I%I%I%I)%T(%I)",
+            "%I%I%I%I->%T(%I)%I->%T(%I)%I%I%I%I%I%I%I%I%I%I%I%I%I%I%I->%T%I%I%I%I%I%I%I%I%I)",
             JB_Type, JB_job_number, JB_ar, JB_exec_file, JB_submission_time, JB_owner,
             JB_uid, JB_group, JB_gid, JB_account, JB_merge_stderr, JB_mail_list,
             JB_project, JB_notify, JB_job_name, JB_stdout_path_list, PN_Type,
@@ -1972,7 +1972,7 @@
             JB_master_hard_queue_list, JB_script_size, JB_pe, RN_Type, JB_pe_range,
             JB_jid_request_list, JB_verify_suitable_queues, JB_soft_wallclock_gmt,
             JB_hard_wallclock_gmt, JB_override_tickets, JB_version,
-            RN_Type, JB_ja_structure); 
+            JB_ja_structure, JB_type); 
    /* get job list */
    alp = ctx->gdi(ctx, SGE_JOB_LIST, SGE_GDI_GET, &jlp, where, what);
    lFreeWhere(&where);
diff --exclude-from=/srv/pbuilder/result/sid/sge_ignore -Naur gridengine-6.2~beta2/source/clients/qstat/qstat_xml.c gridengine-6.2/source/clients/qstat/qstat_xml.c
--- gridengine-6.2~beta2/source/clients/qstat/qstat_xml.c	2008-06-15 15:29:36.000000000 +0100
+++ gridengine-6.2/source/clients/qstat/qstat_xml.c	2008-08-08 18:14:02.000000000 +0100
@@ -1048,7 +1048,7 @@
    /* number of used/free slots */
    xml_append_Attr_I(attribute_list, "slots_used", summary->used_slots); 
    xml_append_Attr_I(attribute_list, "slots_resv", summary->resv_slots); 
-   xml_append_Attr_I(attribute_list, "slots_total", summary->used_slots + summary->free_slots);
+   xml_append_Attr_I(attribute_list, "slots_total", summary->total_slots);
 
    /* load avg */
    if (summary->has_load_value && summary->has_load_value_from_object) {
diff --exclude-from=/srv/pbuilder/result/sid/sge_ignore -Naur gridengine-6.2~beta2/source/clients/qsub/qsub.c gridengine-6.2/source/clients/qsub/qsub.c
--- gridengine-6.2~beta2/source/clients/qsub/qsub.c	2008-06-15 15:29:36.000000000 +0100
+++ gridengine-6.2/source/clients/qsub/qsub.c	2008-08-08 18:14:03.000000000 +0100
@@ -92,8 +92,6 @@
    lListElem *job = NULL;
    lList *alp = NULL;
    lListElem *ep;
-   lListElem *i_opt;
-   lListElem *o_opt;
    int exit_status = 0;
    int just_verify;
    int tmp_ret;
@@ -101,11 +99,11 @@
    dstring session_key_out = DSTRING_INIT;
    dstring diag = DSTRING_INIT;
    dstring jobid = DSTRING_INIT;
-   bool has_terse = false;
    u_long32 start, end, step;
    u_long32 num_tasks;
    int count, stat;
    char *jobid_string = NULL;
+   bool has_terse = false;
    drmaa_attr_values_t *jobids = NULL;
 
    u_long32 prog_number = 0;
@@ -219,20 +217,6 @@
       lRemoveElem(opts_all, &ep);
    }
 
-   i_opt = lGetElemStr(opts_all, SPA_switch, "-i");
-   o_opt = lGetElemStr(opts_all, SPA_switch, "-o");
-
-   if (opt_list_is_X_true(opts_cmdline, "-i")) {
-      if (i_opt == o_opt)  {
-         fprintf(stderr, MSG_PARSE_SAMEPATHFORINPUTANDOUTPUT_SS,
-             "", "");
-         fprintf(stderr, "\n");
-         DEXIT;
-         SGE_EXIT((void**)&ctx, 1);
-      }
-   }
-
-   
    if (wait_for_job) {
       DPRINTF(("Wait for job end\n"));
    }
@@ -375,7 +359,7 @@
 
       /* print the tersed output */
       if (has_terse) {
-        printf("%s", jobid_string);
+         printf("%s", jobid_string);
       } else if (output != NULL) {
         printf("%s", output);
       } else {
diff --exclude-from=/srv/pbuilder/result/sid/sge_ignore -Naur gridengine-6.2~beta2/source/common/msg_common.h gridengine-6.2/source/common/msg_common.h
--- gridengine-6.2~beta2/source/common/msg_common.h	2008-06-15 15:29:37.000000000 +0100
+++ gridengine-6.2/source/common/msg_common.h	2008-08-08 18:14:03.000000000 +0100
@@ -144,7 +144,6 @@
 #define MSG_PARSE_INVALIDPRIORITYMUSTBEINNEG1023TO1024              _MESSAGE(23109, _("ERROR! invalid priority, must be an integer from -1023 to 1024"))
 #define MSG_PARSE_INVALIDJOBSHAREMUSTBEUINT              _MESSAGE(23110, _("ERROR! invalid jobshare, must be an unsigned integer"))
 #define MSG_PARSE_INVALIDOTICKETSMUSTBEUINT              _MESSAGE(23111, _("ERROR! invalid override tickets, must be an unsigned integer"))
-#define MSG_PARSE_SAMEPATHFORINPUTANDOUTPUT_SS              _MESSAGE(231112, _("ERROR! -i argument "SFQ" cannot be the same as -o argument "SFQ))
 
 /*
 ** parse_qconf.c
diff --exclude-from=/srv/pbuilder/result/sid/sge_ignore -Naur gridengine-6.2~beta2/source/common/parse_qsub.c gridengine-6.2/source/common/parse_qsub.c
--- gridengine-6.2~beta2/source/common/parse_qsub.c	2008-06-15 15:29:37.000000000 +0100
+++ gridengine-6.2/source/common/parse_qsub.c	2008-08-08 18:14:03.000000000 +0100
@@ -115,7 +115,6 @@
    char **sp;
    lList *answer = NULL;
    char str[1024 + 1];
-   char i_opt[SGE_PATH_MAX + 1];
    lListElem *ep_opt;
    int i_ret;
    u_long32 is_qalter = flags & FLG_QALTER;
@@ -671,9 +670,6 @@
          ep_opt = sge_add_arg(pcmdline, i_OPT, lListT, *(sp - 1), *sp);
          lSetList(ep_opt, SPA_argval_lListT, path_list);
 
-	 /* Save it for later comparison */
-         strcpy(i_opt, *sp);
-
          sp++;
          continue;
       }
@@ -1023,7 +1019,7 @@
 
          if (lGetElemStr(*pcmdline, SPA_switch, *sp)) {
             answer_list_add_sprintf(&answer, STATUS_EEXIST, ANSWER_QUALITY_WARNING,
-               MSG_PARSE_XOPTIONALREADYSETOVERWRITINGSETING_S, *sp);
+                  MSG_PARSE_XOPTIONALREADYSETOVERWRITINGSETING_S, *sp);
          }
 
          /* next field is name */
@@ -1113,16 +1109,9 @@
                     MSG_PARSE_WRONGSTDOUTPATHLISTFORMATXSPECTOOOPTION_S, *sp );
              DRETURN(answer);
          }
+
          ep_opt = sge_add_arg(pcmdline, o_OPT, lListT, *(sp - 1), *sp);
          lSetList(ep_opt, SPA_argval_lListT, stdout_path_list);
-   
-         if (i_opt != NULL) {
-            if (strcmp(i_opt, *sp) == 0) {
-               answer_list_add_sprintf(&answer, STATUS_ESYNTAX, ANSWER_QUALITY_ERROR,
-               MSG_PARSE_SAMEPATHFORINPUTANDOUTPUT_SS, i_opt, *sp );
-               DRETURN(answer);
-            }
-         }
 
          sp++;
          continue;
@@ -1662,7 +1651,7 @@
          DPRINTF(("\"-w %s\"\n", *sp));
 
          if (!strcmp("e", *sp)) {
-            ep_opt = sge_add_arg(pcmdline, r_OPT, lIntT, *(sp - 1), *sp);
+            ep_opt = sge_add_arg(pcmdline, w_OPT, lIntT, *(sp - 1), *sp);
             if (prog_number == QRSUB) {
                lSetInt(ep_opt, SPA_argval_lIntT, AR_ERROR_VERIFY);
             } else {
@@ -1675,12 +1664,12 @@
                      MSG_PARSE_INVALIDOPTIONARGUMENTWX_S, *sp);
                DRETURN(answer);
             } else {
-               ep_opt = sge_add_arg(pcmdline, r_OPT, lIntT, *(sp - 1), *sp);
+               ep_opt = sge_add_arg(pcmdline, w_OPT, lIntT, *(sp - 1), *sp);
             }
             lSetInt(ep_opt, SPA_argval_lIntT, WARNING_VERIFY);
          }
          else if (!strcmp("n", *sp)) {
-            ep_opt = sge_add_arg(pcmdline, r_OPT, lIntT, *(sp - 1), *sp);
+            ep_opt = sge_add_arg(pcmdline, w_OPT, lIntT, *(sp - 1), *sp);
             if (prog_number == QRSUB) {
                answer_list_add_sprintf(&answer,STATUS_ESYNTAX, ANSWER_QUALITY_ERROR,
                      MSG_PARSE_INVALIDOPTIONARGUMENTWX_S, *sp);
@@ -1690,7 +1679,7 @@
             }
          }
          else if (!strcmp("v", *sp)) {
-            ep_opt = sge_add_arg(pcmdline, r_OPT, lIntT, *(sp - 1), *sp);
+            ep_opt = sge_add_arg(pcmdline, w_OPT, lIntT, *(sp - 1), *sp);
             if (prog_number == QRSUB) {
                lSetInt(ep_opt, SPA_argval_lIntT, AR_JUST_VERIFY);
             } else {
@@ -2357,37 +2346,33 @@
 
    DENTER(TOP_LAYER, "cull_parse_destination_identifier_list");
 
-   if (!lpp) {
-      DEXIT;
-      return 1;
+   if (lpp == NULL) {
+      DRETURN(1);
    }
 
    s = sge_strdup(NULL, dest_str);
-   if (!s) {
+   if (s == NULL) {
       *lpp = NULL;
-      DEXIT;
-      return 3;
+      DRETURN(3);
    }
+
    str_str = string_list(s, ",", NULL);
-   if (!str_str || !*str_str) {
+   if (str_str == NULL || *str_str == NULL) {
       *lpp = NULL;
       FREE(s);
-      DEXIT;
-      return 2;
+      DRETURN(2);
    }
 
    i_ret = cull_parse_string_list(str_str, "destin_ident_list", QR_Type, rule, lpp);
    if (i_ret) {
       FREE(s);
       FREE(str_str);
-      DEXIT;
-      return 3;
+      DRETURN(3);
    }
 
    FREE(s);
    FREE(str_str);
-   DEXIT;
-   return 0;
+   DRETURN(0);
 }
 
 /***************************************************************************/
diff --exclude-from=/srv/pbuilder/result/sid/sge_ignore -Naur gridengine-6.2~beta2/source/common/sge_ijs_comm.c gridengine-6.2/source/common/sge_ijs_comm.c
--- gridengine-6.2~beta2/source/common/sge_ijs_comm.c	2008-06-15 15:29:37.000000000 +0100
+++ gridengine-6.2/source/common/sge_ijs_comm.c	2008-08-08 18:14:03.000000000 +0100
@@ -49,26 +49,215 @@
 #include "sge_utility.h"
 #include "sge_security.h"
 #include "sge_ijs_comm.h"
+#include "sge_mtutil.h"
+#include "msg_commlistslib.h"
+#include "sge_log.h"
+#include "msg_gdilib.h"
 
 extern char *g_hostname;
 extern sig_atomic_t received_signal;
 
+/*
+ * TODO: Cleanup / Headers
+ * This is just slightly modified copy of the gdi commlib error handling,
+ * perhaps it's possible to do minimal changes in the original functions
+ * and remove these.
+ */
+static pthread_mutex_t ijs_general_communication_error_mutex = PTHREAD_MUTEX_INITIALIZER;
+/* local static struct to store communication errors. The boolean
+ * values com_access_denied and com_endpoint_not_unique will never be
+ * restored to false again 
+ */
+typedef struct sge_gdi_com_error_type {
+   int  com_error;                        /* current commlib error */
+   bool com_was_error;                    /* set if there was an communication error (but not CL_RETVAL_ACCESS_DENIED or CL_RETVAL_ENDPOINT_NOT_UNIQUE)*/
+   int  com_last_error;                   /* last logged commlib error */
+   bool com_access_denied;                /* set when commlib reports CL_RETVAL_ACCESS_DENIED */
+   int  com_access_denied_counter;        /* counts access denied errors (TODO: workaround for BT: 6350264, IZ: 1893) */
+   unsigned long com_access_denied_time; /* timeout for counts access denied errors (TODO: workaround for BT: 6350264, IZ: 1893) */
+   bool com_endpoint_not_unique;          /* set when commlib reports CL_RETVAL_ENDPOINT_NOT_UNIQUE */
+   int  com_endpoint_not_unique_counter;  /* counts access denied errors (TODO: workaround for BT: 6350264, IZ: 1893) */
+   unsigned long com_endpoint_not_unique_time; /* timeout for counts access denied errors (TODO: workaround for BT: 6350264, IZ: 1893) */
+} sge_gdi_com_error_t;
+
+
+static sge_gdi_com_error_t ijs_communication_error = {CL_RETVAL_OK,
+                                                      false,
+                                                      CL_RETVAL_OK,
+                                                      false, 0, 0,
+                                                      false, 0, 0};
+
+static bool do_timeout_handling(unsigned long *time, int *counter)
+{
+   struct timeval  now;
+   unsigned long   time_diff = 0;
+   bool            ret = false;
+   
+   gettimeofday(&now, NULL);
+   if ((now.tv_sec - *time) > (3 * CL_DEFINE_READ_TIMEOUT)) {
+      *time = 0;
+      *counter = 0;
+   }
+
+   if (*time < now.tv_sec)  {
+      if (*time == 0) {
+         time_diff = 1;
+      } else {
+         time_diff = now.tv_sec - *time;
+      }
+      *counter += time_diff;
+      if (*counter > 2*CL_DEFINE_READ_TIMEOUT) {
+         ret = true;
+      }
+      *time = now.tv_sec;
+   }
+   return ret;
+}
+
 static void ijs_general_communication_error(
                const cl_application_error_list_elem_t *commlib_error)
 {
-   /* ignore errors */
+   DENTER(TOP_LAYER, "ijs_general_communication_error");
+
+   if (commlib_error == NULL) {
+      DEXIT;
+      return;
+   }
+
+   sge_mutex_lock("ijs_general_communication_error_mutex",
+                  SGE_FUNC, __LINE__, &ijs_general_communication_error_mutex);  
+
+   /* save the communication error to react later */
+   ijs_communication_error.com_error = commlib_error->cl_error;
+
+   switch (commlib_error->cl_error) {
+      case CL_RETVAL_OK:
+         break;
+
+      case CL_RETVAL_ACCESS_DENIED:
+         if (ijs_communication_error.com_access_denied == false) {
+            /* counts access denied errors (TODO: workaround for BT: 6350264, IZ: 1893) */
+            /* increment counter only once per second and allow max CL_DEFINE_READ_TIMEOUT + 2 access denied */
+            ijs_communication_error.com_access_denied =
+               do_timeout_handling(&ijs_communication_error.com_access_denied_time,
+                                   &ijs_communication_error.com_access_denied_counter);
+         }
+         break;
+
+      case CL_RETVAL_ENDPOINT_NOT_UNIQUE: 
+         if (ijs_communication_error.com_endpoint_not_unique == false) {
+            /* counts endpoint not unique errors (TODO: workaround for BT: 6350264, IZ: 1893) */
+            /* increment counter only once per second and allow max CL_DEFINE_READ_TIMEOUT + 2 endpoint not unique */
+            DPRINTF(("got endpint not unique"));
+            ijs_communication_error.com_endpoint_not_unique = 
+               do_timeout_handling(&ijs_communication_error.com_endpoint_not_unique_time,
+                                   &ijs_communication_error.com_endpoint_not_unique_counter);
+         }
+         break;
+
+      default:
+         ijs_communication_error.com_was_error = true;
+         break;
+   }
+
+   /*
+    * now log the error if not already reported the 
+    * least CL_DEFINE_MESSAGE_DUP_LOG_TIMEOUT seconds
+    */
+   if (commlib_error->cl_already_logged == CL_FALSE && 
+      ijs_communication_error.com_last_error != ijs_communication_error.com_error) {
+
+      /*  never log the same messages again and again (commlib
+       *  will erase cl_already_logged flag every CL_DEFINE_MESSAGE_DUP_LOG_TIMEOUT
+       *  seconds (30 seconds), so we have to save the last one!
+       */
+      ijs_communication_error.com_last_error = ijs_communication_error.com_error;
+
+      switch (commlib_error->cl_err_type) {
+         case CL_LOG_ERROR:
+            if (commlib_error->cl_info != NULL) {
+               ERROR((SGE_EVENT, MSG_GDI_GENERAL_COM_ERROR_SS,
+                      cl_get_error_text(commlib_error->cl_error),
+                      commlib_error->cl_info));
+            } else {
+               ERROR((SGE_EVENT, MSG_GDI_GENERAL_COM_ERROR_S,
+                      cl_get_error_text(commlib_error->cl_error)));
+            }
+            break;
+
+         case CL_LOG_WARNING:
+            if (commlib_error->cl_info != NULL) {
+               WARNING((SGE_EVENT, MSG_GDI_GENERAL_COM_ERROR_SS,
+                        cl_get_error_text(commlib_error->cl_error),
+                        commlib_error->cl_info));
+            } else {
+               WARNING((SGE_EVENT, MSG_GDI_GENERAL_COM_ERROR_S,
+                        cl_get_error_text(commlib_error->cl_error)));
+            }
+            break;
+
+         case CL_LOG_INFO:
+            if (commlib_error->cl_info != NULL) {
+               INFO((SGE_EVENT, MSG_GDI_GENERAL_COM_ERROR_SS,
+                     cl_get_error_text(commlib_error->cl_error),
+                     commlib_error->cl_info));
+            } else {
+               INFO((SGE_EVENT, MSG_GDI_GENERAL_COM_ERROR_S,
+                     cl_get_error_text(commlib_error->cl_error)));
+            }
+            break;
+
+         case CL_LOG_DEBUG:
+            if (commlib_error->cl_info != NULL) {
+               DEBUG((SGE_EVENT, MSG_GDI_GENERAL_COM_ERROR_SS,
+                      cl_get_error_text(commlib_error->cl_error),
+                      commlib_error->cl_info));
+            } else {
+               DEBUG((SGE_EVENT, MSG_GDI_GENERAL_COM_ERROR_S,
+                      cl_get_error_text(commlib_error->cl_error)));
+            }
+            break;
+
+         case CL_LOG_OFF:
+            break;
+      }
+   }
+   sge_mutex_unlock("ijs_general_communication_error_mutex", 
+                    SGE_FUNC, __LINE__, &ijs_general_communication_error_mutex);  
+   DRETURN_VOID;
+}
+
+int comm_get_application_error(dstring *err_msg)
+{
+   int ret = COMM_RETVAL_OK;
+
+   DENTER(TOP_LAYER, "comm_get_application_error");
+   sge_mutex_lock("ijs_general_communication_error_mutex", 
+                    SGE_FUNC, __LINE__, &ijs_general_communication_error_mutex);  
+
+   if (ijs_communication_error.com_endpoint_not_unique == true) {
+      sge_dstring_sprintf(err_msg, "%s", MSG_CL_RETVAL_ENDPOINT_NOT_UNIQUE);
+      DPRINTF(("%s", sge_dstring_get_string(err_msg)));
+      ret = COMM_ENDPOINT_NOT_UNIQUE;
+   }
+   if (ijs_communication_error.com_access_denied == true) {
+      sge_dstring_sprintf(err_msg, "%s", MSG_CL_RETVAL_ACCESS_DENIED);
+      DPRINTF(("%s", sge_dstring_get_string(err_msg)));
+      ret = COMM_ACCESS_DENIED;
+   }
+   sge_mutex_unlock("ijs_general_communication_error_mutex", 
+                    SGE_FUNC, __LINE__, &ijs_general_communication_error_mutex);  
+   DRETURN(ret);
 }
 
 /* redirects the commlib logging to a file */
 /* this is a modified copy of the cl_log_list_flush_list() */
-int my_log_list_flush_list(cl_raw_list_t* list_p) {        /* CR check */
-   int ret_val;
-   cl_log_list_elem_t* elem = NULL;
-   struct timeval now;
-
-   FILE *fp = NULL;
+int my_log_list_flush_list(cl_raw_list_t* list_p) {
+   cl_log_list_elem_t *elem = NULL;
+   FILE               *fp = NULL;
+   struct timeval     now;
+   int                ret_val;
 
-   
    if (list_p == NULL) {
       return CL_RETVAL_LOG_NO_LOGLIST;
    }
@@ -82,57 +271,33 @@
    }
 
    while ((elem = cl_log_list_get_first_elem(list_p)) != NULL) {
-      /* TODO: rework logging output (log to file? call foreign log function, got by function pointer ?) */
-
       gettimeofday(&now,NULL);
 
       fprintf(fp, "%-76s|", elem->log_module_name);
       if (elem->log_parameter == NULL) {
-#define CL_COM_PRINT_THREAD_ID 0
-
-#if CL_COM_PRINT_THREAD_ID
-         fprintf(fp, "%ld.%ld|%20s|%4d|%10s|%8s| %s\n",
-#else
          fprintf(fp, "%ld.%ld|%20s|%10s|%8s| %s\n",
-#endif
-
-         (long)now.tv_sec,
-         (long)now.tv_usec,
-         elem->log_thread_name,
-#if CL_COM_PRINT_THREAD_ID
-         elem->log_thread_id, 
-#endif
-         cl_thread_convert_state_id(elem->log_thread_state),
-         cl_log_list_convert_type_id(elem->log_type),
-         elem->log_message);
+                 (long)now.tv_sec,
+                 (long)now.tv_usec,
+                 elem->log_thread_name,
+                 cl_thread_convert_state_id(elem->log_thread_state),
+                 cl_log_list_convert_type_id(elem->log_type),
+                 elem->log_message);
       } else {
-#if CL_COM_PRINT_THREAD_ID
-         fprintf(fp, "%ld.%ld|%20s|%4d|%10s|%8s| %s %s\n",
-#else
          fprintf(fp, "%ld.%ld|%20s|%10s|%8s| %s %s\n",
-#endif
-
-         (long)now.tv_sec,
-         (long)now.tv_usec,
-         elem->log_thread_name,
-#if CL_COM_PRINT_THREAD_ID
-         elem->log_thread_id, 
-#endif
-         cl_thread_convert_state_id(elem->log_thread_state),
-         cl_log_list_convert_type_id(elem->log_type),
-         elem->log_message,
-         elem->log_parameter);
+                 (long)now.tv_sec,
+                 (long)now.tv_usec,
+                 elem->log_thread_name,
+                 cl_thread_convert_state_id(elem->log_thread_state),
+                 cl_log_list_convert_type_id(elem->log_type),
+                 elem->log_message,
+                 elem->log_parameter);
       }
       cl_log_list_del_log(list_p);
       fflush(fp);
    }
 
    fclose(fp);
-
-   if ((ret_val = cl_raw_list_unlock(list_p)) != CL_RETVAL_OK) {
-      return ret_val;
-   } 
-   return CL_RETVAL_OK;
+   return cl_raw_list_unlock(list_p);
 }
 
 /****** sge_ijs_comm/comm_init_lib() *******************************************
@@ -169,7 +334,13 @@
 
    DENTER(TOP_LAYER, "comm_init_lib");
 
-   ret = cl_com_setup_commlib(CL_NO_THREAD, CL_LOG_OFF, NULL /*DEBUG, my_log_list_flush_list*/);
+   /*
+    * To enable commlib logging to a file (see my_log_list_flush_list()
+    * for the file path), exchange this line with the one below.
+    * Caution: On some architectures, logging causes problems! 
+    */
+   /*ret = cl_com_setup_commlib(CL_RW_THREAD, CL_LOG_DEBUG, my_log_list_flush_list);*/
+   ret = cl_com_setup_commlib(CL_RW_THREAD, CL_LOG_OFF, NULL); 
    if (ret != CL_RETVAL_OK) {
       sge_dstring_sprintf(err_msg, cl_get_error_text(ret));
       DPRINTF(("cl_com_setup_commlib() failed: %s (%d)\n",
@@ -199,7 +370,7 @@
 *  RESULT
 *     int - COMM_RETVAL_OK:
 *              Communication library was successfully cleaned up.
-* 
+*
 *           COMM_CANT_CLEANUP_COMMLIB:
 *              Error cleaning up the communication library, err_msg contains
 *              the error reason.
@@ -241,22 +412,24 @@
 *     Either start a comm server or connect to a running comm server.
 *
 *  INPUTS
-*     bool b_server              - If true, a comm server is started, if false
-*                                  a connection to a server is established.
-*     int port                   - In case of server: Port on which the server
-*                                  should listen. If this is 0, a free port is
-*                                  selected.
-*                                  In case of client: Port on which the server
-*                                  listens.
-*     const char *component_name - A unique name for this end of the connection.
-*     bool b_secure              - If true: Use secured connections
-*     const char *user_name      - For secured connections: Name of the user
-*                                  whose certificates are to be used.
-*                                  Ignored for unsecured connections.
+*     bool b_server               - If true, a comm server is started, if false
+*                                   a connection to a server is established.
+*     bool b_secure               - If true: Use secured connections
+*     const char *this_component  - A unique name for this end of the connection.
+*     int port                    - In case of server: Port on which the server
+*                                   should listen. If this is 0, a free port is
+*                                   selected.
+*                                   In case of client: Port on which the server
+*                                   listens.
+*     const char *other_component - The unique name of the other end of the
+*                                   connection.
+*     const char *user_name       - For secured connections: Name of the user
+*                                   whose certificates are to be used.
+*                                   Ignored for unsecured connections.
 *     COMMUNICATION_HANDLE **handle - The address of a COMMUNICATION_HANDLE 
-*                                  pointer which must be initialized to NULL.
-*     dstring *err_msg           - Pointer to an empty dstring to receive
-*                                  error messages.
+*                                   pointer which must be initialized to NULL.
+*     dstring *err_msg            - Pointer to an empty dstring to receive
+*                                   error messages.
 *
 *  OUTPUT
 *    COMMUNICATION_HANDLE **handle - The COMMUNICATION_HANDLE of the connection.
@@ -283,9 +456,10 @@
 *     communication/comm_shutdown_connection()
 *******************************************************************************/
 int comm_open_connection(bool                 b_server, 
-                         int                  port, 
-                         const char           *component_name,
                          bool                 b_secure,
+                         const char           *this_component,
+                         int                  port, 
+                         const char           *other_component,
                          const char           *user_name,
                          COMMUNICATION_HANDLE **handle, 
                          dstring              *err_msg)
@@ -310,14 +484,8 @@
 
    if (b_secure == true) {
 #ifdef SECURE
-      const char *progname    = "pty";
       communication_framework = CL_CT_SSL;
 
-      if (strcmp(component_name, "pty_shepherd") == 0) {
-         /* pretend we are the execd to access it's credentials */
-         progname = "execd";
-      }
-     
       /*
        * Got to do this with euid = root
        */
@@ -325,7 +493,7 @@
          old_euid = geteuid();
          seteuid(SGE_SUPERUSER_UID);
       }
-      ret = sge_ssl_setup_security_path(progname, user_name);
+      ret = sge_ssl_setup_security_path(this_component, user_name);
       /*
        * Switch back to old euid before error handling to do tracing as
        * the SGE admin user.
@@ -370,13 +538,13 @@
             *handle = cl_com_create_handle(&commlib_error, 
                                           communication_framework, 
                                           connection_type, CL_FALSE, port, 
-                                          connect_type, (char*)component_name,
+                                          connect_type, (char*)this_component,
                                           0, 1, 0);
          } else {
             *handle = cl_com_create_handle(&commlib_error, 
                                           communication_framework, 
                                           connection_type, CL_TRUE, port, 
-                                          connect_type, (char*)component_name, 
+                                          connect_type, (char*)this_component, 
                                           1, 1, 0);
          }
 
@@ -390,10 +558,35 @@
             (*handle)->connection_timeout = 0x0fffffff;
             DPRINTF(("(*handle)->connect_port = %d\n", (*handle)->connect_port));
             DPRINTF(("(*handle)->service_port = %d\n", (*handle)->service_port));
+
+            /* Set synchron receive timeout */
+            cl_com_set_synchron_receive_timeout(*handle, 1);
          }
       }
    }
 
+   /*
+    * Need to do this as SUPERUSER, because in csp mode we need the permissions
+    * to load the job users keys.
+    */
+   if (b_server == false) {
+      if (getuid() == SGE_SUPERUSER_UID) {
+         old_euid = geteuid();
+         seteuid(SGE_SUPERUSER_UID);
+      }
+      ret = cl_commlib_open_connection(*handle, g_hostname, (char*)other_component, 1);
+      if (old_euid != SGE_SUPERUSER_UID) {
+         seteuid(old_euid);
+      }
+      if (ret != CL_RETVAL_OK) {
+         ret_val = COMM_CANT_OPEN_CONNECTION;
+      }
+   }
+
+   if (ret_val == COMM_RETVAL_OK) {
+      ret_val = comm_get_application_error(err_msg);
+   }
+
    DEXIT;
    return ret_val;
 }
@@ -439,6 +632,12 @@
 
    DENTER(TOP_LAYER, "comm_shutdown_connection");
 
+   /*
+    * From here on the user shouldn't get informed of any errors occuring
+    * during the shutdown of the connection - just shut down.
+    */
+   ret = cl_com_set_error_func(NULL);
+   cl_com_ignore_timeouts(CL_TRUE);
    ret = cl_commlib_close_connection(handle, g_hostname, 
                                      (char*)component_name, 1, CL_FALSE);
    if (ret != CL_RETVAL_OK) {
@@ -648,11 +847,15 @@
       if (endpoint_list->elem_count > 0) {
          endpoint = cl_endpoint_list_get_first_elem(endpoint_list);
          g_hostname = strdup(endpoint->endpoint->comp_host);
+         FREE(*host);
          *host = g_hostname;
          DPRINTF(("A client from host %s has connected\n", g_hostname));
       }
       cl_endpoint_list_cleanup(&endpoint_list);
    }
+   if (ret_val == COMM_RETVAL_OK) {
+      ret_val = comm_get_application_error(err_msg);
+   }
    DEXIT;
    return ret_val;
 }
@@ -875,6 +1078,9 @@
                sge_dstring_get_string(err_msg), ret));
       ret_val = COMM_CANT_TRIGGER;
    }
+   if (ret_val == COMM_RETVAL_OK) {
+      ret_val = comm_get_application_error(err_msg);
+   }
    DEXIT;
    return ret_val;
 }
@@ -1085,57 +1291,35 @@
       return COMM_INVALID_PARAMETER;
    }
 
-   if (b_synchron == CL_TRUE) {
-      ret = cl_commlib_trigger(handle, 1);
-      if (ret != CL_RETVAL_OK && 
-          ret != CL_RETVAL_SELECT_TIMEOUT &&
-          ret != CL_RETVAL_SELECT_INTERRUPT) {
-         sge_dstring_sprintf(err_msg, cl_get_error_text(ret));
-         DPRINTF(("cl_commlib_trigger() failed: %s (%d)\n",
-                  sge_dstring_get_string(err_msg), ret));
-         ret_val = COMM_CANT_TRIGGER;
-      } else if (ret == CL_RETVAL_SELECT_TIMEOUT) {
-         sge_dstring_sprintf(err_msg, cl_get_error_text(ret));
-         DPRINTF(("cl_commlib_trigger() failed: %s (%d)\n",
-                  sge_dstring_get_string(err_msg), ret));
-         ret_val = COMM_GOT_TIMEOUT;
-      } else if (ret == CL_RETVAL_SELECT_INTERRUPT) {
-         sge_dstring_sprintf(err_msg, cl_get_error_text(ret));
-         ret_val = COMM_SELECT_INTERRUPT;
-      }
-   }
-
-   if (ret_val == COMM_RETVAL_OK) {
-      ret = cl_commlib_receive_message(handle,
-                                       g_hostname, /* unresolved_hostname, */
-                                       NULL, /* component_name, */
-                                       0,    /* component_id, */
-                                       b_synchron,
-                                       0,
-                                       &message,
-                                       &sender);
-      if (ret != CL_RETVAL_OK) {
-         if (ret == CL_RETVAL_NO_SELECT_DESCRIPTORS) {
-            sge_dstring_sprintf(err_msg, cl_get_error_text(ret));
-            DPRINTF(("cl_commlib_receive_message() failed: %s (%d)\n",
-                     sge_dstring_get_string(err_msg), ret));
+   ret = cl_commlib_receive_message(handle,
+                                    g_hostname, /* unresolved_hostname, */
+                                    NULL,       /* component_name, */
+                                    0,          /* component_id, */
+                                    b_synchron,
+                                    0,
+                                    &message,
+                                    &sender);
+   if (ret != CL_RETVAL_OK) {
+      sge_dstring_sprintf(err_msg, cl_get_error_text(ret));
+      DPRINTF(("cl_commlib_receive_message() failed: %s (%d)\n",
+               sge_dstring_get_string(err_msg), ret));
+      switch (ret) {
+         case CL_RETVAL_NO_SELECT_DESCRIPTORS:
             ret_val = COMM_NO_SELECT_DESCRIPTORS;
-         } else if (ret == CL_RETVAL_CONNECTION_NOT_FOUND) {
-            sge_dstring_sprintf(err_msg, cl_get_error_text(ret));
-            DPRINTF(("cl_commlib_receive_message() failed: %s (%d)\n",
-                     sge_dstring_get_string(err_msg), ret));
+         break;
+         case CL_RETVAL_CONNECTION_NOT_FOUND:
             ret_val = COMM_CONNECTION_NOT_FOUND;
-         } else {
-            sge_dstring_sprintf(err_msg, cl_get_error_text(ret));
-            DPRINTF(("cl_commlib_receive_message() failed: %s (%d)\n",
-                     sge_dstring_get_string(err_msg), ret));
+         break;
+         case CL_RETVAL_SYNC_RECEIVE_TIMEOUT:
+            ret_val = COMM_SYNC_RECEIVE_TIMEOUT;
+         break;
+         default:
             ret_val = COMM_CANT_RECEIVE_MESSAGE;
-         }
       }
+   }
 
-      if(sender != NULL) {
-         cl_com_free_endpoint(&sender);
-      }
+   if(sender != NULL) {
+      cl_com_free_endpoint(&sender);
    }
    
    if (ret_val == COMM_RETVAL_OK) {
@@ -1157,19 +1341,21 @@
                   recv_mess->data = (char*)&(message->message[1]);
 
                   DPRINTF(("recv_mess->type = %d\n", recv_mess->type));
-                  snprintf(tmpbuf, MIN(100, message->message_length), "%s", recv_mess->data);
+                  memcpy(tmpbuf, recv_mess->data, MIN(99, message->message_length - 1));
+                  tmpbuf[MIN(99, message->message_length - 1)] = 0;
                   DPRINTF(("recv_mess->data = %s\n", tmpbuf));
                   break;
 
                case WINDOW_SIZE_CTRL_MSG:
+                  memcpy(tmpbuf, message->message, MIN(99, message->message_length));
+                  tmpbuf[MIN(99, message->message_length)] = 0;
                   /* control message */
-                  recv_mess->type = message->message[0];
+                  recv_mess->type = tmpbuf[0];
                   /* scan subtype */
-                  sscanf((char*)&(message->message[1]),
-                     "%s", sub_type);
+                  sscanf((char*)&(tmpbuf[1]), "%s", sub_type);
                   if (strcmp(sub_type, "WS") == 0) {
                      int row, col, xpixel, ypixel;
-                     sscanf((char*)&(message->message[4]),
+                     sscanf((char*)&(tmpbuf[4]),
                         "%d%d%d%d",
                         &row, &col, &xpixel, &ypixel);
                      recv_mess->ws.ws_row    = row;
diff --exclude-from=/srv/pbuilder/result/sid/sge_ignore -Naur gridengine-6.2~beta2/source/common/sge_ijs_comm.h gridengine-6.2/source/common/sge_ijs_comm.h
--- gridengine-6.2~beta2/source/common/sge_ijs_comm.h	2008-06-15 15:29:37.000000000 +0100
+++ gridengine-6.2/source/common/sge_ijs_comm.h	2008-08-08 18:14:03.000000000 +0100
@@ -53,22 +53,26 @@
 #define COMM_CANT_CLEANUP_COMMLIB         3
 #define COMM_CANT_CREATE_HANDLE           4
 #define COMM_CANT_SHUTDOWN_HANDLE         5
-#define COMM_CANT_CLOSE_CONNECTION        6
-#define COMM_CANT_SETUP_SSL               7
-#define COMM_CANT_SET_CONNECTION_PARAM    8
-#define COMM_CANT_SET_IGNORE_TIMEOUTS     9
-#define COMM_GOT_TIMEOUT                 10
-#define COMM_CANT_TRIGGER                11
-#define COMM_CANT_SEARCH_ENDPOINT        12
-#define COMM_CANT_LOCK_CONNECTION_LIST   13
-#define COMM_CANT_UNLOCK_CONNECTION_LIST 14
-#define COMM_CANT_RECEIVE_MESSAGE        15
-#define COMM_CANT_FREE_MESSAGE           16
-#define COMM_CANT_GET_CLIENT_STATUS      17
-#define COMM_NO_SELECT_DESCRIPTORS       18
-#define COMM_CONNECTION_NOT_FOUND        19
-#define COMM_NO_SECURITY_COMPILED_IN     20
-#define COMM_SELECT_INTERRUPT            21
+#define COMM_CANT_OPEN_CONNECTION         6 
+#define COMM_CANT_CLOSE_CONNECTION        7
+#define COMM_CANT_SETUP_SSL               8
+#define COMM_CANT_SET_CONNECTION_PARAM    9
+#define COMM_CANT_SET_IGNORE_TIMEOUTS    10
+#define COMM_GOT_TIMEOUT                 11
+#define COMM_CANT_TRIGGER                12
+#define COMM_CANT_SEARCH_ENDPOINT        13
+#define COMM_CANT_LOCK_CONNECTION_LIST   14
+#define COMM_CANT_UNLOCK_CONNECTION_LIST 15
+#define COMM_CANT_RECEIVE_MESSAGE        16
+#define COMM_CANT_FREE_MESSAGE           17
+#define COMM_CANT_GET_CLIENT_STATUS      18
+#define COMM_NO_SELECT_DESCRIPTORS       19
+#define COMM_CONNECTION_NOT_FOUND        20
+#define COMM_NO_SECURITY_COMPILED_IN     21
+#define COMM_SELECT_INTERRUPT            22
+#define COMM_ENDPOINT_NOT_UNIQUE         23
+#define COMM_ACCESS_DENIED               24
+#define COMM_SYNC_RECEIVE_TIMEOUT        25
 
 typedef struct recv_message_s {
    unsigned char type;
@@ -81,11 +85,16 @@
 int comm_init_lib(dstring *err_msg);
 int comm_cleanup_lib(dstring *err_msg);
 
-int comm_open_connection(bool b_server, int port, 
-                         const char *component_name, bool b_secure,
-                         const char *user_name, COMMUNICATION_HANDLE **handle,
-                         dstring *err_msg);
+int comm_open_connection(bool                 b_server, 
+                         bool                 b_secure,
+                         const char           *this_component,
+                         int                  port, 
+                         const char           *other_component,
+                         const char           *user_name,
+                         COMMUNICATION_HANDLE **handle, 
+                         dstring              *err_msg);
 
+int comm_get_application_error(dstring *err_msg);
 int comm_shutdown_connection(COMMUNICATION_HANDLE *handle,
                              const char *component_name,
                              dstring *err_msg);
diff --exclude-from=/srv/pbuilder/result/sid/sge_ignore -Naur gridengine-6.2~beta2/source/daemons/execd/dispatcher.c gridengine-6.2/source/daemons/execd/dispatcher.c
--- gridengine-6.2~beta2/source/daemons/execd/dispatcher.c	2008-06-15 15:29:44.000000000 +0100
+++ gridengine-6.2/source/daemons/execd/dispatcher.c	2008-08-08 18:14:13.000000000 +0100
@@ -67,12 +67,12 @@
 #   include "sge_smf.h"
 #endif
 
-int sge_execd_process_messages(sge_gdi_ctx_class_t *ctx, char* err_str, void (*errfunc)(const char *))
+int sge_execd_process_messages(sge_gdi_ctx_class_t *ctx)
 {
    monitoring_t monitor;
    bool terminate = false;
    bool do_reconnect = false;
-   int ret = CL_RETVAL_OK;
+   int ret = CL_RETVAL_UNKNOWN;
 
    DENTER(TOP_LAYER, "sge_execd_process_messages");
 
@@ -151,6 +151,18 @@
             clear_packbuffer(&apb);
          }
       } else {
+         switch (ret) {
+            case CL_RETVAL_CONNECTION_NOT_FOUND:  /* we lost connection to qmaster */
+            case CL_RETVAL_CONNECT_ERROR:         /* or we can't connect */
+               do_reconnect = true;
+               break;
+            case CL_RETVAL_NO_MESSAGE:
+            case CL_RETVAL_SYNC_RECEIVE_TIMEOUT:
+               break;
+            default:
+               do_reconnect = true;
+               break;
+         }  
          cl_commlib_trigger(ctx->get_com_handle(ctx), 1);
       }
 
@@ -193,13 +205,9 @@
 
       /* do cyclic stuff */
       if (!terminate) {
-         int check_to_do_ret = do_ck_to_do(ctx);
-
-         if (check_to_do_ret == 1) {
+         if (do_ck_to_do(ctx) == 1) {
             terminate = true;
             ret = CL_RETVAL_OK;
-         } else if (check_to_do_ret == -1) {
-            do_reconnect = true;
          }
       }
    }
diff --exclude-from=/srv/pbuilder/result/sid/sge_ignore -Naur gridengine-6.2~beta2/source/daemons/execd/dispatcher.h gridengine-6.2/source/daemons/execd/dispatcher.h
--- gridengine-6.2~beta2/source/daemons/execd/dispatcher.h	2008-06-15 15:29:43.000000000 +0100
+++ gridengine-6.2/source/daemons/execd/dispatcher.h	2008-08-08 18:14:13.000000000 +0100
@@ -34,6 +34,6 @@
 
 #include "gdi/sge_gdi_ctx.h"
 
-int sge_execd_process_messages(sge_gdi_ctx_class_t *ctx, char* err_str, void (*errfunc)(const char *));
+int sge_execd_process_messages(sge_gdi_ctx_class_t *ctx);
 
 #endif /* _DISPATCHER_H */
diff --exclude-from=/srv/pbuilder/result/sid/sge_ignore -Naur gridengine-6.2~beta2/source/daemons/execd/execd.c gridengine-6.2/source/daemons/execd/execd.c
--- gridengine-6.2~beta2/source/daemons/execd/execd.c	2008-08-15 16:39:37.000000000 +0100
+++ gridengine-6.2/source/daemons/execd/execd.c	2008-08-15 16:38:26.000000000 +0100
@@ -90,7 +90,6 @@
 
 static void execd_exit_func(void **ctx, int i);
 static void execd_register(sge_gdi_ctx_class_t *ctx);
-static void dispatcher_errfunc(const char *err_str);
 static void parse_cmdline_execd(char **argv);
 static lList *sge_parse_cmdline_execd(char **argv, lList **ppcmdline);
 static lList *sge_parse_execd(lList **ppcmdline, lList **ppreflist, u_long32 *help);
@@ -323,7 +322,6 @@
 
    /***** MAIN LOOP *****/
    while (shut_me_down != 1) {
-      char err_str[1024];
 
      if (thread_prof_active_by_id(pthread_self())) {
          prof_start(SGE_PROF_CUSTOM1, NULL);
@@ -337,7 +335,7 @@
 
       PROF_START_MEASUREMENT(SGE_PROF_CUSTOM1);
 
-      ret = sge_execd_process_messages(ctx, err_str, dispatcher_errfunc);
+      ret = sge_execd_process_messages(ctx);
 
       if (sge_sig_handler_sigpipe_received) {
           sge_sig_handler_sigpipe_received = 0;
@@ -355,14 +353,8 @@
          break; /* shut down, leave while */
       }
 
-      if (ret) {
-         if (cl_is_commlib_error(ret)) {
-            if (ret != CL_RETVAL_OK) {
-               execd_register(ctx); /* reregister at qmaster */
-            }
-         } else {
-            WARNING((SGE_EVENT, MSG_COM_RECEIVEREQUEST_S, err_str));
-         }
+      if (shut_me_down != 1) {
+         execd_register(ctx); /* reregister at qmaster */
       }
    }
 
@@ -421,18 +413,6 @@
    DEXIT;
 }
 
-/*-------------------------------------------------------------
- * dispatcher_errfunc
- *
- * function called by dispatcher on non terminal errors 
- *-------------------------------------------------------------*/
-static void dispatcher_errfunc(const char *err_str)
-{
-   DENTER(TOP_LAYER, "dispatcher_errfunc");
-   ERROR((SGE_EVENT, "%s", err_str));
-   DEXIT;
-}
-
 /****** execd/sge_execd_register_at_qmaster() **********************************
 *  NAME
 *     sge_execd_register_at_qmaster() -- modify execd list at qmaster site
diff --exclude-from=/srv/pbuilder/result/sid/sge_ignore -Naur gridengine-6.2~beta2/source/daemons/execd/execd_ck_to_do.c gridengine-6.2/source/daemons/execd/execd_ck_to_do.c
--- gridengine-6.2~beta2/source/daemons/execd/execd_ck_to_do.c	2008-06-15 15:29:44.000000000 +0100
+++ gridengine-6.2/source/daemons/execd/execd_ck_to_do.c	2008-08-08 18:14:13.000000000 +0100
@@ -549,31 +549,14 @@
    }
 
    /* handle shutdown */
-   switch (shut_me_down) {
-      case 1:
-         return_value = 1; /* tell dispatcher to finish server */
-         break;
-      case 0:
-         return_value = 0;
-         break;
-      default:
-         /* if shut_me_down == 2 we wait one "dispatch epoche"
-            and we hope that all the killed jobs are reaped 
-            reaped jobs will be reported to qmaster 
-            since sge_get_flush_flag() is set in this case
-         */
-         if (lGetNumberOfElem(*(object_type_get_master_list(SGE_TYPE_JOB))) == 0) { /* no need to delay shutdown */
-            return_value = 1;
-         } else {
-            DPRINTF(("DELAYED SHUTDOWN\n"));
-            shut_me_down--;
-            return_value = 0;
-         }
-   }
+   return_value = shut_me_down;
+
+   /* TODO: Why not check shut_me_down in dispatcher - and remove this terminate loop from dispatcher */
 
    if (return_value == 0 && was_communication_error != CL_RETVAL_OK) {
       DPRINTF(("was_communication_error is %s\n", cl_get_error_text(was_communication_error)));
       return_value = 1;  /* leave dispatcher */
+      /* TODO: check if we really must leave dispatcher when a commlib error occurs !!!*/
    }
 
    DRETURN(return_value);
diff --exclude-from=/srv/pbuilder/result/sid/sge_ignore -Naur gridengine-6.2~beta2/source/daemons/execd/execd_job_exec.c gridengine-6.2/source/daemons/execd/execd_job_exec.c
--- gridengine-6.2~beta2/source/daemons/execd/execd_job_exec.c	2008-06-15 15:29:44.000000000 +0100
+++ gridengine-6.2/source/daemons/execd/execd_job_exec.c	2008-08-08 18:14:13.000000000 +0100
@@ -67,6 +67,7 @@
 #include "sgeobj/sge_object.h"
 #include "sge_bootstrap.h"
 #include "sge_answer.h"
+#include "sge_ckpt.h"
 
 #include "msg_common.h"
 #include "msg_execd.h"
@@ -115,8 +116,14 @@
          DRETURN(0);
       }
 
-      if (!job_verify_execd_job(job, &answer_list)) {
-         lFreeElem(&job);
+      if (!job_verify_execd_job(job, &answer_list, ctx->get_qualified_hostname(ctx))) {
+         lListElem *ja_task = lFirst(lGetList(job, JB_ja_tasks));
+         const char *err_str = lGetString(lFirst(answer_list), AN_text);
+
+         /* set the job into error state */
+         execd_job_start_failure(job, ja_task, NULL, err_str, GFSTATE_JOB);
+
+         /* error output to messages file, cleanup */
          answer_list_output(&answer_list);
          ERROR((SGE_EVENT, MSG_EXECD_INVALIDJOBREQUEST_SS, aMsg->snd_name, aMsg->snd_host));
          DRETURN(0);
@@ -793,3 +800,142 @@
 
    DRETURN(-1);
 }
+
+/****** execd/job/job_verify_execd_job() *****************************************
+*  NAME
+*     job_verify_execd_job() -- verify a job entering execd
+*
+*  SYNOPSIS
+*     bool 
+*     job_verify_execd_job(const lListElem *job, lList **answer_list) 
+*
+*  FUNCTION
+*     Verifies a job object entering execd.
+*     Does generic tests by calling job_verify, like verifying the cull
+*     structure, and makes sure a number of job attributes are set
+*     correctly.
+*
+*  INPUTS
+*     const lListElem *job - the job to verify
+*     lList **answer_list  - answer list to pass back error messages
+*
+*  RESULT
+*     bool - true on success,
+*            false on error with error message in answer_list
+*
+*  NOTES
+*     MT-NOTE: job_verify_execd_job() is MT safe 
+*
+*  BUGS
+*     The function is far from being complete.
+*     Currently, only the CULL structure is verified, not the contents.
+*
+*  SEE ALSO
+*     sge_job/job_verify()
+*******************************************************************************/
+bool
+job_verify_execd_job(const lListElem *job, lList **answer_list, const char *qualified_hostname)
+{
+   bool ret = true;
+
+   DENTER(TOP_LAYER, "job_verify_execd_job");
+
+   ret = job_verify(job, answer_list);
+
+   /* 
+    * A job entering execd must have some additional properties:
+    *    - correct state
+    *    - JB_job_number > 0
+    *    - JB_job_name != NULL
+    *    - JB_exec_file etc. ???
+    *    - JB_submission_time, JB_execution_time??
+    *    - JB_owner != NULL
+    *    - JB_cwd != NULL??
+    */
+
+   if (ret) {
+      ret = object_verify_ulong_not_null(job, answer_list, JB_job_number);
+   }
+
+   if (ret) {
+      ret = object_verify_string_not_null(job, answer_list, JB_job_name);
+   }
+
+   if (ret) {
+      ret = object_verify_string_not_null(job, answer_list, JB_owner);
+   }
+
+   if (ret) {
+      const lListElem *ckpt = lGetObject(job, JB_checkpoint_object);
+      if (ckpt != NULL) {
+         if (ckpt_validate(ckpt, answer_list) != STATUS_OK) {
+            ret = false;
+         }
+      }
+   }
+
+   /* for job execution, we need exactly one ja task */
+   if (ret) {
+      const lList *ja_tasks = lGetList(job, JB_ja_tasks);
+
+      if (ja_tasks == NULL || lGetNumberOfElem(ja_tasks) != 1) {
+         answer_list_add_sprintf(answer_list, STATUS_ESYNTAX, ANSWER_QUALITY_ERROR, 
+                           MSG_JOB_INVALIDJATASK_REQUEST);
+         ret = false;
+      }
+
+      /* verify the ja task structure */
+      if (ret) {
+         ret = ja_task_verify_execd_job(lFirst(ja_tasks), answer_list);
+      }
+   }
+
+   /* 
+    * JB_stdout_path_list, JB_stderr_path_list, JB_stdin_path_list
+    * validate, stdin may not be the same as stdout or stderr
+    * except, when it is "/dev/null".
+    */
+   if (ret) {
+      char stdin_path[SGE_PATH_MAX];
+      char stdout_path[SGE_PATH_MAX];
+      char stderr_path[SGE_PATH_MAX];
+      u_long32 job_id = lGetUlong(job, JB_job_number);
+      u_long32 ja_task_id = lGetUlong(lFirst(lGetList(job, JB_ja_tasks)), JAT_task_number);
+
+      sge_get_path(qualified_hostname,
+                   lGetList(job, JB_stdin_path_list), "",
+                   lGetString(job, JB_owner), 
+                   lGetString(job, JB_job_name),
+                   job_id,
+                   job_is_array(job) ? ja_task_id : 0,
+                   SGE_STDIN, stdin_path, SGE_PATH_MAX);
+      sge_get_path(qualified_hostname,
+                   lGetList(job, JB_stdout_path_list), "", 
+                   lGetString(job, JB_owner), 
+                   lGetString(job, JB_job_name),
+                   job_id,
+                   job_is_array(job) ? ja_task_id : 0,
+                   SGE_STDOUT, stdout_path, SGE_PATH_MAX);
+      sge_get_path(qualified_hostname,
+                   lGetList(job, JB_stderr_path_list), "",
+                   lGetString(job, JB_owner), 
+                   lGetString(job, JB_job_name),
+                   job_id,
+                   job_is_array(job) ? ja_task_id : 0,
+                   SGE_STDERR, stderr_path, SGE_PATH_MAX);
+      if (strcmp(stdin_path, "/dev/null") != 0) {
+         if (strcmp(stdin_path, stdout_path) == 0) {
+            answer_list_add_sprintf(answer_list, STATUS_ESYNTAX, ANSWER_QUALITY_ERROR, 
+                              MSG_JOB_SAMEPATHSFORINPUTANDOUTPUT_SSS, stdin_path, "stdout", stdout_path);
+            ret = false;
+         } else if (strcmp(stdin_path, stderr_path) == 0) {
+            answer_list_add_sprintf(answer_list, STATUS_ESYNTAX, ANSWER_QUALITY_ERROR, 
+                              MSG_JOB_SAMEPATHSFORINPUTANDOUTPUT_SSS, stdin_path, "stderr", stderr_path);
+            ret = false;
+         }
+      }
+   }
+
+   DRETURN(ret);
+}
+
diff --exclude-from=/srv/pbuilder/result/sid/sge_ignore -Naur gridengine-6.2~beta2/source/daemons/execd/execd_job_exec.h gridengine-6.2/source/daemons/execd/execd_job_exec.h
--- gridengine-6.2~beta2/source/daemons/execd/execd_job_exec.h	2008-06-15 15:29:43.000000000 +0100
+++ gridengine-6.2/source/daemons/execd/execd_job_exec.h	2008-08-08 18:14:13.000000000 +0100
@@ -38,4 +38,6 @@
 
 int do_job_slave(sge_gdi_ctx_class_t *ctx, struct_msg_t *aMsg);
 
+bool job_verify_execd_job(const lListElem *job, lList **answer_list, const char *qualified_hostname);
+
 #endif /* __EXECD_JOB_EXEC_H */
diff --exclude-from=/srv/pbuilder/result/sid/sge_ignore -Naur gridengine-6.2~beta2/source/daemons/execd/exec_job.c gridengine-6.2/source/daemons/execd/exec_job.c
--- gridengine-6.2~beta2/source/daemons/execd/exec_job.c	2008-06-15 15:29:43.000000000 +0100
+++ gridengine-6.2/source/daemons/execd/exec_job.c	2008-08-08 18:14:13.000000000 +0100
@@ -975,7 +975,18 @@
    fprintf(fp, "h_fsize=%s\n", lGetString(master_q, QU_h_fsize));
    fprintf(fp, "s_vmem=%s\n", lGetString(master_q, QU_s_vmem));
    fprintf(fp, "h_vmem=%s\n", lGetString(master_q, QU_h_vmem));
+   {
+      char *s;
 
+      mconf_get_s_descriptors(&s); fprintf(fp, "s_descriptors=%s\n", s); free(s);
+      mconf_get_h_descriptors(&s); fprintf(fp, "h_descriptors=%s\n", s); free(s);
+      mconf_get_s_maxproc(&s); fprintf(fp, "s_maxproc=%s\n", s); free(s);
+      mconf_get_h_maxproc(&s); fprintf(fp, "h_maxproc=%s\n", s); free(s);
+      mconf_get_s_memorylocked(&s); fprintf(fp, "s_memorylocked=%s\n", s); free(s);
+      mconf_get_h_memorylocked(&s); fprintf(fp, "h_memorylocked=%s\n", s); free(s);
+      mconf_get_s_locks(&s); fprintf(fp, "s_locks=%s\n", s); free(s);
+      mconf_get_h_locks(&s); fprintf(fp, "h_locks=%s\n", s); free(s);
+   }
 
    fprintf(fp, "priority=%s\n", lGetString(master_q, QU_priority));
    fprintf(fp, "shell_path=%s\n", shell_path);
diff --exclude-from=/srv/pbuilder/result/sid/sge_ignore -Naur gridengine-6.2~beta2/source/daemons/execd/load_avg.c gridengine-6.2/source/daemons/execd/load_avg.c
--- gridengine-6.2~beta2/source/daemons/execd/load_avg.c	2008-06-15 15:29:43.000000000 +0100
+++ gridengine-6.2/source/daemons/execd/load_avg.c	2008-08-08 18:14:13.000000000 +0100
@@ -165,6 +165,7 @@
    DENTER(TOP_LAYER, "execd_add_load_report");
 
    if (*next_send <= now || sge_get_flush_lr_flag()) {
+      lSortOrder *order = lParseSortOrderVarArg(LR_Type, "%I+", LR_host);
       lListElem *report;
       lList *tmp_lr_list;
 
@@ -192,6 +193,7 @@
       if (lr_list == NULL) {
          lr_list = lCopyList("", tmp_lr_list);
          lFreeElem(&last_lr);
+         lSortList(tmp_lr_list, order);
          lSetList(report, REP_list, tmp_lr_list);
       } else {
          lListElem *lr;
@@ -232,10 +234,13 @@
                lAppendElem(tmp_lr_list, del_report);
             }
          }
+
+         lSortList(tmp_lr_list, order);
          lSetList(report, REP_list, tmp_lr_list);
          lFreeElem(&last_lr);
          last_lr = lCopyElem(report);
       }
+      lFreeSortOrder(&order);
 
       lAppendElem(report_list, report);
       send_all = false;
diff --exclude-from=/srv/pbuilder/result/sid/sge_ignore -Naur gridengine-6.2~beta2/source/daemons/execd/msg_execd.h gridengine-6.2/source/daemons/execd/msg_execd.h
--- gridengine-6.2~beta2/source/daemons/execd/msg_execd.h	2008-06-15 15:29:44.000000000 +0100
+++ gridengine-6.2/source/daemons/execd/msg_execd.h	2008-08-08 18:14:13.000000000 +0100
@@ -230,12 +230,9 @@
 #define MSG_JOB_TASKWITHOUTJOB_U      _MESSAGE(29140, _("received task belongs to job "sge_U32CFormat" but this job is not here"))
 #define MSG_JOB_TASKNOTASKINJOB_UU    _MESSAGE(29141, _("received task belongs to job "sge_U32CFormat" but this job is here but the JobArray task "sge_U32CFormat" is not here"))
 #define MSG_JOB_TASKNOSUITABLEJOB_U   _MESSAGE(29142, _("received task belongs to job "sge_U32CFormat" but this job is not suited for starting tasks"))
-/* #define MSG_JOB_TASKALREADYEXISTS_US  _message(29143, _("received task "sge_U32CFormat"/"SFN" which is already here")) __TS Removed automatically from testsuite!! TS__*/
-/* #define MSG_JOB_NOTASKPASSINGIF_SU    _message(29144, _(SFN" does not fulfill task passing interface for job "sge_U32CFormat)) __TS Removed automatically from testsuite!! TS__*/
 #define MSG_JOB_NOFREEQ_USSS          _MESSAGE(29145, _("no free queue for job "sge_U32CFormat" of user "SFN"@"SFN" (localhost = "SFN")"))
-/* #define MSG_JOB_NOSUCHQ_SUSS          _message(29146, _("no such queue "SFQ" as requested by job "sge_U32CFormat" from user "SFN"@"SFN)) __TS Removed automatically from testsuite!! TS__*/
-/* #define MSG_JOB_NOREQQONHOST_SSS      _message(29147, _("requested queue "SFQ" resides not at this host "SFN" but at host "SFN)) __TS Removed automatically from testsuite!! TS__*/
-/* #define MSG_JOB_REQQFULL_SII          _message(29148, _("requested queue "SFQ" is already full (%d/%d)")) __TS Removed automatically from testsuite!! TS__*/
+#define MSG_JOB_INVALIDJATASK_REQUEST _MESSAGE(29146, _("invalid task list in job start request"))
+#define MSG_JOB_SAMEPATHSFORINPUTANDOUTPUT_SSS   _MESSAGE(29147, _("same paths given for stdin ("SFQ") and "SFN" ("SFQ")"))
 /*
 ** execd_kill_execd.c
 */
diff --exclude-from=/srv/pbuilder/result/sid/sge_ignore -Naur gridengine-6.2~beta2/source/daemons/execd/reaper_execd.c gridengine-6.2/source/daemons/execd/reaper_execd.c
--- gridengine-6.2~beta2/source/daemons/execd/reaper_execd.c	2008-06-15 15:29:43.000000000 +0100
+++ gridengine-6.2/source/daemons/execd/reaper_execd.c	2008-08-08 18:14:13.000000000 +0100
@@ -847,7 +847,7 @@
    /* try to find this job in our job list */ 
 
    jep = lGetElemUlongFirst(*(object_type_get_master_list(SGE_TYPE_JOB)), JB_job_number, job_id, &iterator);
-   while(jep != NULL) {
+   while (jep != NULL) {
       jatep = job_search_task(jep, NULL, ja_task_id);
       if (jatep != NULL) {
          break;
@@ -1086,14 +1086,16 @@
 int failed 
 ) {
    lListElem *jr, *ep;
-   u_long32 jobid, jataskid;
+   u_long32 jobid, jataskid = 0;
    const char *petaskid = NULL;
 
    DENTER(TOP_LAYER, "execd_job_failure");
 
    jobid = lGetUlong(jep, JB_job_number);
-   jataskid = lGetUlong(jatep, JAT_task_number);
-   if(petep != NULL) {
+   if (jatep != NULL) {
+      jataskid = lGetUlong(jatep, JAT_task_number);
+   }
+   if (petep != NULL) {
       petaskid = lGetString(petep, PET_id);
    }
 
@@ -1126,8 +1128,7 @@
 
    job_related_adminmail(EXECD, jr, job_is_array(jep), lGetString(jep, JB_owner));
 
-   DEXIT;
-   return jr;
+   DRETURN(jr);
 }
 
 
diff --exclude-from=/srv/pbuilder/result/sid/sge_ignore -Naur gridengine-6.2~beta2/source/daemons/qmaster/msg_qmaster.h gridengine-6.2/source/daemons/qmaster/msg_qmaster.h
--- gridengine-6.2~beta2/source/daemons/qmaster/msg_qmaster.h	2008-06-15 15:29:43.000000000 +0100
+++ gridengine-6.2/source/daemons/qmaster/msg_qmaster.h	2008-08-08 18:14:12.000000000 +0100
@@ -223,7 +223,6 @@
 #define MSG_JOB_DELIVER2Q_UUS         _MESSAGE(33148, _("failed to deliver job "sge_U32CFormat"."sge_U32CFormat" to queue "SFQ))
 #define MSG_JOB_RESCHEDULE_UU         _MESSAGE(33159, _("rescheduling job "sge_U32CFormat"."sge_U32CFormat) ) 
 #define MSG_RU_CANCELED_S             _MESSAGE(33160, _("Due to a modification of the reschedule_unknown timeout rescheduling for host "SFN" was canceled."))
-#define MSG_JOB_DEPENDUPT4J_UU        _MESSAGE(33161, _("failed to update dependent tasks of completed job "sge_U32CFormat"."sge_U32CFormat)) 
 
 /* CR: don't localize mail subject, until we send it in Mime format!
  *  The message definition is not l10n'ed (no _() macro used)!!!     
diff --exclude-from=/srv/pbuilder/result/sid/sge_ignore -Naur gridengine-6.2~beta2/source/daemons/qmaster/sge_advance_reservation_qmaster.c gridengine-6.2/source/daemons/qmaster/sge_advance_reservation_qmaster.c
--- gridengine-6.2~beta2/source/daemons/qmaster/sge_advance_reservation_qmaster.c	2008-06-15 15:29:43.000000000 +0100
+++ gridengine-6.2/source/daemons/qmaster/sge_advance_reservation_qmaster.c	2008-08-08 18:14:12.000000000 +0100
@@ -1079,6 +1079,15 @@
     */
    a.queue_list = lCreateList("", QU_Type);
 
+    /* imagine qs is empty */
+    sconf_set_qs_state(QS_STATE_EMPTY);
+
+   /* redirect scheduler monitoring into answer list */
+   if (verify_mode == AR_JUST_VERIFY) {
+      DPRINTF(("AR Verify Mode\n"));
+      set_monitor_alpp(&talp);
+   }
+
    for_each(cqueue, master_cqueue_list) {
       const char *cqname = lGetString(cqueue, CQ_name);
       lList *qinstance_list = lGetList(cqueue, CQ_qinstances);
@@ -1158,8 +1167,7 @@
       splitted_job_lists[SPLIT_RUNNING] = &running_list;
 
       /* splitted job lists must be freed */
-      split_jobs(&master_job_list, NULL, a.queue_list, 
-                 mconf_get_max_aj_instances(), splitted_job_lists, false, true);
+      split_jobs(&master_job_list, mconf_get_max_aj_instances(), splitted_job_lists, true);
    }
 
    /*
@@ -1183,14 +1191,6 @@
    lSetUlong(dummy_job, JB_type, lGetUlong(ar, AR_type));
    lSetString(dummy_job, JB_checkpoint_name, lGetString(ar, AR_checkpoint_name));
 
-    /* imagine qs is empty */
-    sconf_set_qs_state(QS_STATE_EMPTY);
-
-   /* redirect scheduler monitoring into answer list */
-   if (verify_mode == AR_JUST_VERIFY) {
-      DPRINTF(("AR Verify Mode\n"));
-      set_monitor_alpp(&talp);
-   }
 
    if (lGetString(ar, AR_pe)) {
       lSetString(dummy_job, JB_pe, lGetString(ar, AR_pe));
diff --exclude-from=/srv/pbuilder/result/sid/sge_ignore -Naur gridengine-6.2~beta2/source/daemons/qmaster/sge_follow.c gridengine-6.2/source/daemons/qmaster/sge_follow.c
--- gridengine-6.2~beta2/source/daemons/qmaster/sge_follow.c	2008-06-15 15:29:42.000000000 +0100
+++ gridengine-6.2/source/daemons/qmaster/sge_follow.c	2008-08-08 18:14:11.000000000 +0100
@@ -554,8 +554,7 @@
          if (job_number == 0) {
             ERROR((SGE_EVENT, MSG_JOB_NOJOBID));
             answer_list_add(alpp, SGE_EVENT, STATUS_EUNKNOWN, ANSWER_QUALITY_ERROR);
-            DEXIT;
-            return -2;
+            DRETURN(-2);
          }
          
          task_number = lGetUlong(ep, OR_ja_task_number);
@@ -563,11 +562,10 @@
          DPRINTF(("ORDER : job("sge_u32")->pri/tickets reset"));
 
          jep = job_list_locate(*object_base[SGE_TYPE_JOB].list, job_number);
-         if(jep == NULL) {
+         if (jep == NULL) {
             WARNING((SGE_EVENT, MSG_JOB_UNABLE2FINDJOBORD_U, sge_u32c(job_number)));
             answer_list_add(alpp, SGE_EVENT, STATUS_EUNKNOWN, ANSWER_QUALITY_WARNING);
-            DEXIT;
-            return 0; /* it's ok - job has exited - forget about him */
+            DRETURN(0); /* it's ok - job has exited - forget about him */
          }
        
          next_ja_task = lFirst(lGetList(jep, JB_ja_tasks));
@@ -577,8 +575,7 @@
          if (jatp == NULL) {
             ERROR((SGE_EVENT, MSG_JOB_FINDJOBTASK_UU,  
                   sge_u32c(0), sge_u32c(job_number)));
-            DEXIT;
-            return -2;
+            DRETURN(-2);
          }
       
          sge_mutex_lock("follow_last_update_mutex", SGE_FUNC, __LINE__, &Follow_Control.last_update_mutex);
@@ -598,8 +595,7 @@
                if (task_number != 0) { /* if task_number == 0, we only change the */
                   jatp = next_ja_task; /* pending tickets, otherwise all */
                   next_ja_task = lNext(next_ja_task);
-               }
-               else {
+               } else {
                   jatp = NULL;
                }
             }
@@ -622,8 +618,7 @@
                if (task_number != 0) {   /* if task_number == 0, we only change the */
                   jatp = next_ja_task;   /* pending tickets, otherwise all */
                   next_ja_task = lNext(next_ja_task);
-               }
-               else {
+               } else {
                   jatp = NULL;
                }
             }
@@ -634,7 +629,6 @@
             lSetDouble(jep, JB_rrcontr, 0);
             lSetDouble(jep, JB_dlcontr, 0);
             lSetDouble(jep, JB_wtcontr, 0);
-            
          }
          
          sge_mutex_unlock("follow_last_update_mutex", SGE_FUNC, __LINE__, &Follow_Control.last_update_mutex);         
@@ -662,48 +656,47 @@
          lListElem *joker;
 
          job_number=lGetUlong(ep, OR_job_number);
-         if(!job_number) {
+         if (!job_number) {
             ERROR((SGE_EVENT, MSG_JOB_NOJOBID));
             answer_list_add(alpp, SGE_EVENT, STATUS_EUNKNOWN, ANSWER_QUALITY_ERROR);
-            DEXIT;
-            return -2;
+            DRETURN(-2);
          }
 
          DPRINTF(("ORDER : job("sge_u32")->ticket = "sge_u32"\n", 
             job_number, (u_long32)lGetDouble(ep, OR_ticket)));
 
          jep = job_list_locate(*object_base[SGE_TYPE_JOB].list, job_number);
-         if(!jep) {
+         if (!jep) {
             WARNING((SGE_EVENT, MSG_JOB_UNABLE2FINDJOBORD_U, sge_u32c(job_number)));
             answer_list_add(alpp, SGE_EVENT, STATUS_EUNKNOWN, ANSWER_QUALITY_WARNING);
-            DEXIT;
-            return 0; /* it's ok - job has exited - forget about him */
+            DRETURN(0); /* it's ok - job has exited - forget about him */
          }
+
          task_number=lGetUlong(ep, OR_ja_task_number);
          if (!task_number) {
             ERROR((SGE_EVENT, MSG_JOB_NOORDERTASK_US, sge_u32c(job_number), "ORT_ptickets"));
             answer_list_add(alpp, SGE_EVENT, STATUS_EUNKNOWN, ANSWER_QUALITY_ERROR);
-            DEXIT;
-            return -2;
+            DRETURN(-2);
          }
+
          jatp = job_search_task(jep, NULL, task_number);
          if (!jatp) {
             jatp = job_get_ja_task_template_pending(jep, task_number);
-         }
-         if (!jatp) {
-            ERROR((SGE_EVENT, MSG_JOB_FINDJOBTASK_UU,  
-                  sge_u32c(task_number), sge_u32c(job_number)));
-            sge_add_event( 0, sgeE_JATASK_DEL, job_number, task_number, 
-                          NULL, NULL, lGetString(jep, JB_session), NULL);
-            DEXIT;
-            return -2;
+
+            if (!jatp) {
+               ERROR((SGE_EVENT, MSG_JOB_FINDJOBTASK_UU,  
+                     sge_u32c(task_number), sge_u32c(job_number)));
+               sge_add_event( 0, sgeE_JATASK_DEL, job_number, task_number, 
+                             NULL, NULL, lGetString(jep, JB_session), NULL);
+               DRETURN(-2);
+            }
          }
       
          sge_mutex_lock("follow_last_update_mutex", SGE_FUNC, __LINE__, &Follow_Control.last_update_mutex);
          
          if (Follow_Control.cull_order_pos == NULL) {
             lListElem *joker_task;
-            
+
             joker=lFirst(lGetList(ep, OR_joker));
             joker_task = lFirst(lGetList(joker, JB_ja_tasks));
             
@@ -722,8 +715,7 @@
                      sge_u32c(lGetUlong(jatp, JAT_task_number))));
             answer_list_add(alpp, SGE_EVENT, STATUS_EEXIST, ANSWER_QUALITY_WARNING);
             sge_mutex_unlock("follow_last_update_mutex", SGE_FUNC, __LINE__, &Follow_Control.last_update_mutex);
-            DEXIT;
-            return 0;
+            DRETURN(0);
          }
 
          /* modify jobs ticket amount */
@@ -969,6 +961,7 @@
     * (former ORT_remove_interactive_job)
     * ----------------------------------------------------------------------- */
    case ORT_remove_immediate_job:
+      DPRINTF(("ORDER: ORT_remove_immediate_job or ORT_remove_job\n"));
 
       job_number=lGetUlong(ep, OR_job_number);
       if(!job_number) {
@@ -1494,11 +1487,14 @@
          
          if (sub_order_list != NULL) {
             lListElem *sme  = lFirst(sub_order_list);
+         
 
             if (sme != NULL) {
                lListElem *first;
                lList **master_job_schedd_info_list = object_base[SGE_TYPE_JOB_SCHEDD_INFO].list;
 
+               DPRINTF(("ORDER: got %d schedd infos\n", lGetNumberOfElem(lGetList(sme, SME_message_list))));
+
                while ((first = lFirst(*master_job_schedd_info_list))) {
                   lRemoveElem(*master_job_schedd_info_list, &first);
                }
diff --exclude-from=/srv/pbuilder/result/sid/sge_ignore -Naur gridengine-6.2~beta2/source/daemons/qmaster/sge_give_jobs.c gridengine-6.2/source/daemons/qmaster/sge_give_jobs.c
--- gridengine-6.2~beta2/source/daemons/qmaster/sge_give_jobs.c	2008-06-15 15:29:42.000000000 +0100
+++ gridengine-6.2/source/daemons/qmaster/sge_give_jobs.c	2008-08-08 18:14:11.000000000 +0100
@@ -1524,10 +1524,6 @@
 
       /* infer reverse dependencies from the completed predecessor task to this successor */
       if (sge_task_depend_get_range(&suc_range, NULL, suc_jep, jep, task_id)) {
-         /* JA: this should not really happen at all.. maybe make it a proper error? */ 
-         u_long32 job_id = lGetUlong(jep, JB_job_number);
-         DPRINTF(("unknown error computing dependants of task %lu.%lu\n", job_id, task_id));
-         WARNING((SGE_EVENT, MSG_JOB_DEPENDUPT4J_UU, sge_u32c(job_id), sge_u32c(task_id)));
          lFreeElem(&suc_range);
          continue;
       }
diff --exclude-from=/srv/pbuilder/result/sid/sge_ignore -Naur gridengine-6.2~beta2/source/daemons/qmaster/sge_host_qmaster.c gridengine-6.2/source/daemons/qmaster/sge_host_qmaster.c
--- gridengine-6.2~beta2/source/daemons/qmaster/sge_host_qmaster.c	2008-06-15 15:29:42.000000000 +0100
+++ gridengine-6.2/source/daemons/qmaster/sge_host_qmaster.c	2008-08-08 18:14:11.000000000 +0100
@@ -557,7 +557,7 @@
          lList *master_userset_list = *(object_type_get_master_list(SGE_TYPE_USERSET));
 
          for_each(ar, *(object_type_get_master_list(SGE_TYPE_AR))) {
-            if (lGetElemStr(lGetList(ar, AR_granted_slots), JG_qhostname, host)) {
+            if (lGetElemHost(lGetList(ar, AR_granted_slots), JG_qhostname, host)) {
                if (!sge_ar_have_users_access(NULL, ar, host, lGetList(ep, EH_acl),
                                              lGetList(ep, EH_xacl),
                                              master_userset_list)) {
@@ -700,11 +700,12 @@
 void sge_update_load_values(sge_gdi_ctx_class_t *ctx, const char *rhost, lList *lp)
 {
    u_long32 now;
-   const char *report_host = NULL;
    lListElem *ep, **hepp = NULL;
    lListElem *lep;
-   lListElem *global_ep = NULL, *host_ep = NULL;
-   bool added_non_static = false, statics_changed = false;
+   lListElem *global_ep = NULL;
+   lListElem *host_ep = NULL;
+   bool statics_changed = false;
+   lList *answer_list = NULL;
 
    DENTER(TOP_LAYER, "sge_update_load_values");
 
@@ -713,6 +714,22 @@
     */
    now = sge_get_gmt();
 
+   host_ep = host_list_locate(*object_type_get_master_list(SGE_TYPE_EXECHOST), rhost);
+   if (host_ep == NULL) {
+      /* report from unknown host arrived, ignore it */
+      DRETURN_VOID;
+   }
+
+   /* 
+    * if rhost is unknown set him to known
+    */
+   if (lGetUlong(host_ep, EH_lt_heard_from) == 0) {
+      cqueue_list_set_unknown_state(*(object_type_get_master_list(SGE_TYPE_CQUEUE)),
+                                    rhost, true, false);
+      lSetUlong(host_ep, EH_lt_heard_from, sge_get_gmt());
+   }
+
+   host_ep = NULL;
    /* loop over all received load values */
    for_each(ep, lp) {
 
@@ -735,14 +752,22 @@
          hepp = &host_ep;
       }
 
-      /* update load value list of rhost */
-      if (*hepp == NULL) {
+      /* update load value list of reported host */
+      if (*hepp == NULL || sge_hostcmp(host, lGetHost(*hepp, EH_name)) != 0) {
+   
+         if (*hepp != NULL) {
+            /* we have a host change, send events for the previous one */
+            sge_event_spool(ctx, &answer_list, 0, sgeE_EXECHOST_MOD, 
+                            0, 0, lGetHost(*hepp, EH_name), NULL, NULL,
+                            host_ep, NULL, NULL, true, statics_changed);
+            reporting_create_host_record(&answer_list, *hepp, now);
+            statics_changed = false;
+         }
+
+         /* get the new host */
          *hepp = host_list_locate(*object_type_get_master_list(SGE_TYPE_EXECHOST), host);
-         if (!*hepp) {
-            if (!global) {
-               report_host = host; /* this is our error indicator */
-            }
-            DPRINTF(("got load value for UNKNOWN host "SFQ"\n", host));
+         if (*hepp == NULL) {
+            INFO((SGE_EVENT, MSG_CANT_ASSOCIATE_LOAD_SS, rhost, host));
             continue;
          }
       } 
@@ -763,10 +788,6 @@
             lep = lAddSubStr(*hepp, HL_name, name, EH_load_list, HL_Type);
             DPRINTF(("%s: adding load value: "SFQ" = "SFQ"\n", 
                   host, name, value));
-
-            if (!global) {
-               added_non_static = true; /* triggers clearing of unknown state */
-            }
          } 
 
          /* copy value */
@@ -776,48 +797,25 @@
       }
    }
 
-   /* output error from previous host, if any */
-   if (report_host) {
-      INFO((SGE_EVENT, MSG_CANT_ASSOCIATE_LOAD_SS, rhost, report_host));
-   }
-
-   /* 
-    * if non static load values arrived, this indicates that 
-    * host is known 
-    */
-   if (added_non_static && lGetUlong(host_ep, EH_lt_heard_from) == 0) {
-      const char* tmp_hostname;
+   /*
+   ** if static load values (eg arch) have changed
+   ** then spool
+   */
+   if (hepp != NULL && *hepp != NULL) {
+      sge_event_spool(ctx, &answer_list, 0, sgeE_EXECHOST_MOD, 
+                      0, 0, lGetHost(*hepp, EH_name), NULL, NULL,
+                      *hepp, NULL, NULL, true, statics_changed);
 
-      tmp_hostname = lGetHost(host_ep, EH_name);
-      cqueue_list_set_unknown_state(
-         *(object_type_get_master_list(SGE_TYPE_CQUEUE)),
-         tmp_hostname, true, false);
-      lSetUlong(host_ep, EH_lt_heard_from, sge_get_gmt());
+      reporting_create_host_record(&answer_list, *hepp, now);
    }
 
    if (global_ep) {
-      lList *answer_list = NULL;
       sge_event_spool(ctx, &answer_list, 0, sgeE_EXECHOST_MOD, 
                       0, 0, SGE_GLOBAL_NAME, NULL, NULL,
                       global_ep, NULL, NULL, true, false);
       reporting_create_host_record(&answer_list, global_ep, now);
-      answer_list_output(&answer_list);
-   }
-
-   /*
-   ** if static load values (eg arch) have changed
-   ** then spool
-   */
-   if (host_ep) {
-      lList *answer_list = NULL;
-
-      sge_event_spool(ctx, &answer_list, 0, sgeE_EXECHOST_MOD, 
-                      0, 0, lGetHost(host_ep, EH_name), NULL, NULL,
-                      host_ep, NULL, NULL, true, statics_changed);
-
-      reporting_create_host_record(&answer_list, host_ep, now);
-      answer_list_output(&answer_list);
    }
+   answer_list_output(&answer_list);
 
    DRETURN_VOID;
 }
diff --exclude-from=/srv/pbuilder/result/sid/sge_ignore -Naur gridengine-6.2~beta2/source/daemons/qmaster/sge_job_qmaster.c gridengine-6.2/source/daemons/qmaster/sge_job_qmaster.c
--- gridengine-6.2~beta2/source/daemons/qmaster/sge_job_qmaster.c	2008-06-15 15:29:42.000000000 +0100
+++ gridengine-6.2/source/daemons/qmaster/sge_job_qmaster.c	2008-08-08 18:14:11.000000000 +0100
@@ -167,7 +167,7 @@
 
 static u_long32 guess_highest_job_number(void);
 
-static int verify_suitable_queues(lList **alpp, lListElem *jep, int *trigger);
+static int verify_suitable_queues(lList **alpp, lListElem *jep, int *trigger, bool is_modify);
 
 static int job_verify_predecessors(lListElem *job, lList **alpp);
 
@@ -743,7 +743,7 @@
 
       /* verify schedulability */
       {
-         int ret = verify_suitable_queues(alpp, jep, NULL); 
+         int ret = verify_suitable_queues(alpp, jep, NULL, false); 
          if (lGetUlong(jep, JB_verify_suitable_queues)==JUST_VERIFY || ret != 0) {
             DRETURN(ret);
          }   
@@ -1631,6 +1631,21 @@
          continue;
       }
 
+      /* ignore modify requests if all job tasks are already JFINISHED 
+         and no task id remains in not yet ran task id lists */
+      if (job_get_not_enrolled_ja_tasks(jobep) == 0) {
+         lListElem *ja_task;
+         bool all_finished = true;
+         for_each (ja_task, lGetList(jobep, JB_ja_tasks)) {
+            if (lGetUlong(ja_task, JAT_status) != JFINISHED) {
+               all_finished = false;
+               break;
+            }
+         }
+         if (all_finished == true)
+            continue;
+      }
+
       njobs++;
       jobid = lGetUlong(jobep, JB_job_number);
 
@@ -1733,6 +1748,24 @@
             }
          }
 
+         if (trigger & RECHAIN_JA_AD_HOLD) {
+            lListElem *suc_jobep, *jid;
+            for_each(jid, lGetList(jobep, JB_ja_ad_predecessor_list)) {
+               u_long32 pre_ident = lGetUlong(jid, JRE_job_number);
+
+               DPRINTF((" JOB #"sge_u32": P: "sge_u32"\n", jobid, pre_ident)); 
+
+               if ((suc_jobep = job_list_locate(*(object_type_get_master_list(SGE_TYPE_JOB)), pre_ident))) {
+                  lListElem *temp_job = NULL;
+   
+                  temp_job = lGetElemUlong(lGetList(suc_jobep, JB_ja_ad_successor_list), JRE_job_number, jobid);               
+                  DPRINTF(("  JOB "sge_u32" removed from trigger "
+                     "list of job "sge_u32"\n", jobid, pre_ident));
+                  lRemoveElem(lGetList(suc_jobep, JB_ja_ad_successor_list), &temp_job);
+               } 
+            }
+         }
+
          /* write data back into job list  */
          {
             lListElem *prev = lPrev(jobep);
@@ -1744,6 +1777,8 @@
          /* no need to spool these mods */
          if (trigger & RECHAIN_JID_HOLD) 
             job_suc_pre(new_job);
+         if (trigger & RECHAIN_JA_AD_HOLD) 
+            job_suc_pre_ad(new_job);
 
          INFO((SGE_EVENT, MSG_SGETEXT_MODIFIEDINLIST_SSUS, ruser, 
                rhost, sge_u32c(jobid), MSG_JOB_JOB));
@@ -1820,6 +1855,7 @@
          if (lGetList(parent_jep, JB_ja_n_h_ids) != NULL ||
              lGetList(parent_jep, JB_ja_u_h_ids) != NULL ||
              lGetList(parent_jep, JB_ja_o_h_ids) != NULL ||
+             lGetList(parent_jep, JB_ja_a_h_ids) != NULL ||
              lGetList(parent_jep, JB_ja_s_h_ids) != NULL) {
             Exited = 0;
          }
@@ -3066,7 +3102,7 @@
       int ret;
       lSetUlong(new_job, JB_verify_suitable_queues, 
             lGetUlong(jep, JB_verify_suitable_queues));
-      ret = verify_suitable_queues(alpp, new_job, trigger); 
+      ret = verify_suitable_queues(alpp, new_job, trigger, true); 
       if (lGetUlong(new_job, JB_verify_suitable_queues)==JUST_VERIFY 
          || ret != 0) {
          DRETURN(ret);
@@ -3661,188 +3697,198 @@
 }   
       
 /* all modifications are done now verify schedulability */
-static int verify_suitable_queues(lList **alpp, lListElem *jep, int *trigger)
+static int verify_suitable_queues(lList **alpp, lListElem *jep, int *trigger, bool is_modify)
 {
    int verify_mode = lGetUlong(jep, JB_verify_suitable_queues);
 
    DENTER(TOP_LAYER, "verify_suitable_queues");
-   
-   switch (verify_mode) {
-   case SKIP_VERIFY:   
+
+   if (verify_mode == SKIP_VERIFY) {
       DPRINTF(("skip expensive verification of schedulability\n"));
-      break;
-   case ERROR_VERIFY:
-   case WARNING_VERIFY:
-   case JUST_VERIFY:
-   default:
-      {
-         lListElem *cqueue;
-         lList *talp = NULL;
-         int ngranted = 0;
-         int try_it = 1;
-         const char *ckpt_name;
-         lList *job_hard_queue_list = lGetList(jep, JB_hard_queue_list);
-         const char *pe_name = lGetString(jep, JB_pe);
-         object_description *object_base = object_type_get_object_description();
-
-         sge_assignment_t a = SGE_ASSIGNMENT_INIT;
-
-         assignment_init(&a, jep, NULL, false);
-
-         DPRINTF(("verify schedulability = %c\n", OPTION_VERIFY_STR[verify_mode]));
-
-         /* checkpointing */
-         if ((ckpt_name=lGetString(jep, JB_checkpoint_name)))
-            if (!(a.ckpt = ckpt_list_locate(*object_base[SGE_TYPE_CKPT].list, ckpt_name)))
-               try_it = 0;
-
-         /* parallel */
-         if (try_it) {
-            u_long32 ar_id = lGetUlong(jep, JB_ar);
-            lList *ar_granted_slots = NULL;
-
-            if (ar_id != 0) {
-               lListElem *ar = NULL; 
-               ar = ar_list_locate(*object_base[SGE_TYPE_AR].list, ar_id);
-               if (ar != NULL) {
-                  ar_granted_slots = lGetList(ar, AR_granted_slots);
-               }
+      DRETURN(0);
+   }     
+
+   /* can happen only from qalter -w ... */
+   if (is_modify == true && job_get_not_enrolled_ja_tasks(jep) == 0) {
+      /* since we can rule out a finished jobs it can be running only */
+      sprintf(SGE_EVENT, "verification: job is already running");
+      answer_list_add(alpp, SGE_EVENT, STATUS_OK, ANSWER_QUALITY_INFO);
+      DRETURN(0);
+   }  
+ 
+   {
+      lListElem *cqueue;
+      lList *talp = NULL;
+      int ngranted = 0;
+      int try_it = 1;
+      const char *ckpt_name;
+      lList *job_hard_queue_list = lGetList(jep, JB_hard_queue_list);
+      const char *pe_name = lGetString(jep, JB_pe);
+      object_description *object_base = object_type_get_object_description();
+
+      sge_assignment_t a = SGE_ASSIGNMENT_INIT;
+
+      assignment_init(&a, jep, NULL, false);
+
+      DPRINTF(("verify schedulability = %c\n", OPTION_VERIFY_STR[verify_mode]));
+
+      /* checkpointing */
+      if ((ckpt_name=lGetString(jep, JB_checkpoint_name)))
+         if (!(a.ckpt = ckpt_list_locate(*object_base[SGE_TYPE_CKPT].list, ckpt_name)))
+            try_it = 0;
+
+      /* parallel */
+      if (try_it) {
+         u_long32 ar_id = lGetUlong(jep, JB_ar);
+         lList *ar_granted_slots = NULL;
+
+         if (ar_id != 0) {
+            lListElem *ar = NULL; 
+            ar = ar_list_locate(*object_base[SGE_TYPE_AR].list, ar_id);
+            if (ar != NULL) {
+               ar_granted_slots = lGetList(ar, AR_granted_slots);
             }
+         }
 
-            a.host_list        = *object_base[SGE_TYPE_EXECHOST].list;
-            a.centry_list      = *object_base[SGE_TYPE_CENTRY].list;
-            a.acl_list         = *object_base[SGE_TYPE_USERSET].list;
-            a.hgrp_list        = *object_base[SGE_TYPE_HGROUP].list;
-            if (lGetUlong(jep, JB_ar) == 0) {
-               a.rqs_list         = *object_base[SGE_TYPE_RQS].list;
-            } else {
-               a.ar_list         = *object_base[SGE_TYPE_AR].list;
+         a.host_list        = *object_base[SGE_TYPE_EXECHOST].list;
+         a.centry_list      = *object_base[SGE_TYPE_CENTRY].list;
+         a.acl_list         = *object_base[SGE_TYPE_USERSET].list;
+         a.hgrp_list        = *object_base[SGE_TYPE_HGROUP].list;
+         if (lGetUlong(jep, JB_ar) == 0) {
+            a.rqs_list         = *object_base[SGE_TYPE_RQS].list;
+         } else {
+            a.ar_list         = *object_base[SGE_TYPE_AR].list;
+         }
+         a.gep              = host_list_locate(*object_base[SGE_TYPE_EXECHOST].list, SGE_GLOBAL_NAME);
+         a.start            = DISPATCH_TIME_NOW;
+         a.duration         = 0; /* indicator for schedule based mode */
+         a.is_job_verify    = true;
+
+         /* 
+          * Current scheduler code expects all queue instances in a plain list. We use 
+          * a copy of all queue instances that needs to be free'd explicitely after 
+          * deciding about assignment. This is because assignment_release() sees 
+          * queue_list only as a list pointer.
+          */ 
+         a.queue_list = lCreateList("", QU_Type);
+
+         /* imagine qs is empty */
+         sconf_set_qs_state(QS_STATE_EMPTY);
+
+         /* redirect scheduler monitoring into answer list */
+         if (verify_mode == JUST_VERIFY) {
+            set_monitor_alpp(&talp);
+         }
+
+         for_each(cqueue, *object_base[SGE_TYPE_CQUEUE].list) {
+            const char *cqname = lGetString(cqueue, CQ_name);
+            lList *qinstance_list = lGetList(cqueue, CQ_qinstances);
+            lListElem *qinstance;
+
+            if (cqueue_match_static(cqname, &a) != DISPATCH_OK) {
+               continue;
             }
-            a.gep              = host_list_locate(*object_base[SGE_TYPE_EXECHOST].list, SGE_GLOBAL_NAME);
-            a.start            = DISPATCH_TIME_NOW;
-            a.duration         = 0; /* indicator for schedule based mode */
-            a.is_job_verify    = true;
 
-            /* 
-             * Current scheduler code expects all queue instances in a plain list. We use 
-             * a copy of all queue instances that needs to be free'd explicitely after 
-             * deciding about assignment. This is because assignment_release() sees 
-             * queue_list only as a list pointer.
-             */ 
-            a.queue_list = lCreateList("", QU_Type);
-
-            for_each(cqueue, *object_base[SGE_TYPE_CQUEUE].list) {
-               const char *cqname = lGetString(cqueue, CQ_name);
-               lList *qinstance_list = lGetList(cqueue, CQ_qinstances);
-               lListElem *qinstance;
+            for_each(qinstance, qinstance_list) {
 
-               if (cqueue_match_static(cqname, &a) != DISPATCH_OK) {
-                  continue;
+               /* we only have to consider requested queues */
+               if (job_hard_queue_list != NULL) {
+                  if (qref_list_cq_rejected(job_hard_queue_list, cqname,
+                           lGetHost(qinstance, QU_qhostname), a.hgrp_list)) {
+                     continue; 
+                  } 
                }
 
-               for_each(qinstance, qinstance_list) {
-
-                  /* we only have to consider requested queues */
-                  if (job_hard_queue_list != NULL) {
-                     if (qref_list_cq_rejected(job_hard_queue_list, cqname,
-                              lGetHost(qinstance, QU_qhostname), a.hgrp_list)) {
-                        continue; 
-                     } 
+               if (ar_granted_slots != NULL) {
+                  if (lGetElemStr(ar_granted_slots, JG_qname, lGetString(qinstance, QU_full_name)) == NULL) {
+                    continue; 
                   }
+               }
+               
 
-                  if (ar_granted_slots != NULL) {
-                     if (lGetElemStr(ar_granted_slots, JG_qname, lGetString(qinstance, QU_full_name)) == NULL) {
-                       continue; 
+               /* we only have to consider queues containing the requested pe */
+               if (pe_name != NULL) {
+                  bool found = false;
+                  lListElem *pe_ref;
+
+                  for_each(pe_ref, lGetList(qinstance, QU_pe_list)) {
+                     if (pe_name_is_matching(lGetString(pe_ref, ST_name), pe_name)) {
+                        found = true;
+                        break;
                      }
                   }
-                  
-
-                  /* we only have to consider queues containing the requested pe */
-                  if (pe_name != NULL) {
-                     bool found = false;
-                     lListElem *pe_ref;
-
-                     for_each(pe_ref, lGetList(qinstance, QU_pe_list)) {
-                        if (pe_name_is_matching(lGetString(pe_ref, ST_name), pe_name)) {
-                           found = true;
-                           break;
-                        }
-                     }
-                     if (!found) {
-                        continue;
-                     }
-
+                  if (!found) {
+                     continue;
                   }
 
-                  lAppendElem(a.queue_list, lCopyElem(qinstance));
                }
+
+               lAppendElem(a.queue_list, lCopyElem(qinstance));
             }
+         }
 
+         if (pe_name) {
+            sge_select_parallel_environment(&a, *object_base[SGE_TYPE_PE].list);
+         } else {
+            sge_sequential_assignment(&a);
+         }
+         ngranted = nslots_granted(a.gdil, NULL);
 
-            /* imagine qs is empty */
-            sconf_set_qs_state(QS_STATE_EMPTY);
+         /* stop redirection of scheduler monitoring messages */
+         if (verify_mode==JUST_VERIFY) {
+            set_monitor_alpp(NULL);
+         }
 
-            /* redirect scheduler monitoring into answer list */
-            if (verify_mode == JUST_VERIFY) {
-               set_monitor_alpp(&talp);
-            }   
+         /* stop dreaming */
+         sconf_set_qs_state(QS_STATE_FULL);
 
-            if (lGetString(jep, JB_pe)) {
-               sge_select_parallel_environment(&a, *object_base[SGE_TYPE_PE].list);
-            } else {
-               sge_sequential_assignment(&a);
-            }
-            ngranted += nslots_granted(a.gdil, NULL);
-
-            /* stop redirection of scheduler monitoring messages */
-            if (verify_mode==JUST_VERIFY) {
-               set_monitor_alpp(NULL);
-            }
+         lFreeList(&(a.queue_list));
+      }
 
-            /* stop dreaming */
-            sconf_set_qs_state(QS_STATE_FULL);
+      assignment_release(&a);
 
-            lFreeList(&(a.queue_list));
+      /* consequences */
+      if (!try_it || !ngranted) {
+         /* copy error msgs from talp into alpp */
+         if (verify_mode==JUST_VERIFY) {
+            if (!*alpp)
+               *alpp = lCreateList("answer", AN_Type);
+            lAddList(*alpp, &talp);
+         } else {
+            lFreeList(&talp);
          }
 
-         assignment_release(&a);
-
-         /* consequences */
-         if (!ngranted || !try_it) {
-            /* copy error msgs from talp into alpp */
-            if (verify_mode==JUST_VERIFY) {
-               if (!*alpp)
-                  *alpp = lCreateList("answer", AN_Type);
-               lAddList(*alpp, &talp);
-            } else {
-               lFreeList(&talp);
-            }
+         if (verify_mode == JUST_VERIFY) {
+            SGE_ADD_MSG_ID(sprintf(SGE_EVENT, MSG_JOB_NOSUITABLEQ_S, MSG_JOB_VERIFYVERIFY));
+         } else if (verify_mode == ERROR_VERIFY) {
+            SGE_ADD_MSG_ID(sprintf(SGE_EVENT, MSG_JOB_NOSUITABLEQ_S, MSG_JOB_VERIFYERROR));
+         } else {
+            SGE_ADD_MSG_ID(sprintf(SGE_EVENT, MSG_JOB_NOSUITABLEQ_S, MSG_JOB_VERIFYWARN));
+         }
 
-            SGE_ADD_MSG_ID(sprintf(SGE_EVENT, MSG_JOB_NOSUITABLEQ_S,
-               (verify_mode==JUST_VERIFY ? MSG_JOB_VERIFYVERIFY: 
-                  (verify_mode==ERROR_VERIFY)?MSG_JOB_VERIFYERROR:MSG_JOB_VERIFYWARN)));
-            answer_list_add(alpp, SGE_EVENT, STATUS_ESEMANTIC, (verify_mode==JUST_VERIFY ? ANSWER_QUALITY_INFO: 
-                  (verify_mode==ERROR_VERIFY)?ANSWER_QUALITY_ERROR:ANSWER_QUALITY_WARNING));
+         if (verify_mode == JUST_VERIFY || verify_mode == ERROR_VERIFY) {
+            answer_list_add(alpp, SGE_EVENT, STATUS_ESEMANTIC, ANSWER_QUALITY_ERROR); 
+         } else {
+            answer_list_add(alpp, SGE_EVENT, STATUS_ESEMANTIC, ANSWER_QUALITY_WARNING); 
+         }
 
-            if (verify_mode != WARNING_VERIFY) {
-               DRETURN((verify_mode==JUST_VERIFY)?0:STATUS_ESEMANTIC);
-            }
+         if (verify_mode != WARNING_VERIFY) {
+            DRETURN((verify_mode==JUST_VERIFY)?0:STATUS_ESEMANTIC);
          }
+      }
 
-         if (verify_mode==JUST_VERIFY) {
-            if (trigger) {
-               *trigger |= VERIFY_EVENT;
-            }
-            if (!a.pe) {
-               sprintf(SGE_EVENT, MSG_JOB_VERIFYFOUNDQ); 
-            } else {
-               sprintf(SGE_EVENT, MSG_JOB_VERIFYFOUNDSLOTS_I, ngranted);
-            }
-            answer_list_add(alpp, SGE_EVENT, STATUS_OK, ANSWER_QUALITY_INFO);
-            DRETURN(0);
+      if (verify_mode == JUST_VERIFY) {
+         if (trigger) {
+            *trigger |= VERIFY_EVENT;
+         }
+         if (!a.pe) {
+            sprintf(SGE_EVENT, MSG_JOB_VERIFYFOUNDQ); 
+         } else {
+            sprintf(SGE_EVENT, MSG_JOB_VERIFYFOUNDSLOTS_I, ngranted);
          }
+         answer_list_add(alpp, SGE_EVENT, STATUS_OK, ANSWER_QUALITY_INFO);
+         DRETURN(STATUS_ESEMANTIC);
       }
-      break;
    }
 
    DRETURN(0);
diff --exclude-from=/srv/pbuilder/result/sid/sge_ignore -Naur gridengine-6.2~beta2/source/daemons/qmaster/sge_persistence_qmaster.c gridengine-6.2/source/daemons/qmaster/sge_persistence_qmaster.c
--- gridengine-6.2~beta2/source/daemons/qmaster/sge_persistence_qmaster.c	2008-06-15 15:29:42.000000000 +0100
+++ gridengine-6.2/source/daemons/qmaster/sge_persistence_qmaster.c	2008-08-08 18:14:11.000000000 +0100
@@ -61,8 +61,8 @@
 
    DENTER(TOP_LAYER, "sge_initialize_persistence");
 
-   if (getenv("SGE_TEST_SPOOLING_WAIT_TIME_US") != NULL) {
-         spooling_wait_time=atoi(getenv("SGE_TEST_SPOOLING_WAIT_TIME_US"));
+   if (getenv("SGE_TEST_SPOOLING_WAIT_TIME") != NULL) {
+         spooling_wait_time=atoi(getenv("SGE_TEST_SPOOLING_WAIT_TIME"));
    }
 
    /* create spooling context */
@@ -243,12 +243,28 @@
    /*for testing a fixed gid_error, this has been introduced. We need it to slowdown*/
    /*the spooling mechanism, to simulate the situation where this error appears*/ 
    if (spooling_wait_time != 0) {
-      static unsigned long sleep_time = 0;
-      if (sleep_time == 0) {
-         sleep_time = spooling_wait_time;
-      }
-      usleep(sleep_time);
-      sleep_time = sleep_time + 100000;
+      unsigned long sleep_time = spooling_wait_time;
+      bool do_sleep = false;
+      do {
+         /* 
+          * find out if there is a qping -dump client connected to qmaster
+          */         
+         cl_com_handle_t* handle = cl_com_get_handle("qmaster",1);
+         if (handle != NULL) {
+            if (handle->debug_client_setup != NULL) {
+               if (handle->debug_client_setup->dc_mode != CL_DEBUG_CLIENT_OFF) {
+                  do_sleep = true;
+               } else {
+                  do_sleep = false;
+               }
+            }
+         }
+
+         if (do_sleep == true) {
+            usleep(1000000);
+            sleep_time--;
+         }
+      } while (sleep_time > 0 && do_sleep == true);
    }
 
    switch (event) {
diff --exclude-from=/srv/pbuilder/result/sid/sge_ignore -Naur gridengine-6.2~beta2/source/daemons/qmaster/sge_qmaster_process_message.c gridengine-6.2/source/daemons/qmaster/sge_qmaster_process_message.c
--- gridengine-6.2~beta2/source/daemons/qmaster/sge_qmaster_process_message.c	2008-06-15 15:29:43.000000000 +0100
+++ gridengine-6.2/source/daemons/qmaster/sge_qmaster_process_message.c	2008-08-08 18:14:12.000000000 +0100
@@ -250,7 +250,6 @@
        * requests would be handled by read-only threads.
        */
       init_packbuffer(&(packet->pb), 0, 0);
-#else
 #endif
 
       /*
@@ -281,7 +280,9 @@
       sge_gdi_packet_free(&packet);
 #  endif
 #endif
-   } 
+   } else {
+      sge_gdi_packet_free(&packet);
+   }
 
    DRETURN_VOID;
 }
diff --exclude-from=/srv/pbuilder/result/sid/sge_ignore -Naur gridengine-6.2~beta2/source/daemons/qmaster/sge_reporting_qmaster.c gridengine-6.2/source/daemons/qmaster/sge_reporting_qmaster.c
--- gridengine-6.2~beta2/source/daemons/qmaster/sge_reporting_qmaster.c	2008-06-15 15:29:43.000000000 +0100
+++ gridengine-6.2/source/daemons/qmaster/sge_reporting_qmaster.c	2008-08-08 18:14:11.000000000 +0100
@@ -1014,7 +1014,6 @@
       sge_dstring_free(&consumable_dstring);
    }
 
-
    DRETURN(ret);
 }
 
@@ -1494,7 +1493,6 @@
       if (fp != NULL) {
          FCLOSE(fp);
       }
-
    }
 
    sge_mutex_unlock(buf->mtx_name, SGE_FUNC, __LINE__, &(buf->mtx));
diff --exclude-from=/srv/pbuilder/result/sid/sge_ignore -Naur gridengine-6.2~beta2/source/daemons/qmaster/sge_sched_thread.c gridengine-6.2/source/daemons/qmaster/sge_sched_thread.c
--- gridengine-6.2~beta2/source/daemons/qmaster/sge_sched_thread.c	2008-06-15 15:29:42.000000000 +0100
+++ gridengine-6.2/source/daemons/qmaster/sge_sched_thread.c	2008-08-08 18:14:11.000000000 +0100
@@ -204,8 +204,7 @@
    splitted_job_lists[SPLIT_HOLD] = &hold_list;
    splitted_job_lists[SPLIT_NOT_STARTED] = &not_started_list;
 
-   split_jobs(&(lists->job_list), NULL, lists->all_queue_list,
-              mconf_get_max_aj_instances(), splitted_job_lists, false, false);
+   split_jobs(&(lists->job_list), mconf_get_max_aj_instances(), splitted_job_lists, false);
 
    if (lists->all_queue_list != NULL) { /* add global queue messages */
       lList *qlp = NULL;
diff --exclude-from=/srv/pbuilder/result/sid/sge_ignore -Naur gridengine-6.2~beta2/source/daemons/qmaster/sge_task_depend.c gridengine-6.2/source/daemons/qmaster/sge_task_depend.c
--- gridengine-6.2~beta2/source/daemons/qmaster/sge_task_depend.c	2008-06-15 15:29:42.000000000 +0100
+++ gridengine-6.2/source/daemons/qmaster/sge_task_depend.c	2008-08-08 18:14:11.000000000 +0100
@@ -114,17 +114,20 @@
 
    if (range == NULL || 
          pre_jep == NULL || 
-         suc_jep == NULL ||
-         task_id == 0) {
+         suc_jep == NULL) {
       DRETURN(STATUS_EUNKNOWN);
    }
 
    job_get_submit_task_ids(pre_jep, &a0, &a1, &sa);
    job_get_submit_task_ids(suc_jep, &b0, &b1, &sb);
 
-   /* do some basic checks on the input */
-   if (!sge_task_depend_is_same_range(pre_jep, suc_jep) || 
-       ((task_id - 1) % sb) != 0) {
+   /* sanity check on task ranges */
+   if (!sge_task_depend_is_same_range(pre_jep, suc_jep)) {
+      DRETURN(STATUS_EUNKNOWN);
+   }
+
+   /* make sure task_id is the first task in a range */
+   if (task_id < b0 || ((task_id - b0) % sb) != 0) {
       DRETURN(STATUS_EUNKNOWN);
    }
 
@@ -149,7 +152,6 @@
    DRETURN(0);
 }
 
-
 /*****************************************************************************
  Tasks matching this profile are considered finished for dependence purposes
  *****************************************************************************/
@@ -254,7 +256,6 @@
       /* use the RSP functions to determine dependent predecessor task range */
       if (sge_task_depend_get_range(&dep_range, alpp, pred_jep, jep, task_id)) {
          /* since we can't calculate it, we must assume dependence */
-         DPRINTF(("could not calculate dependent iteration ranges for a job\n"));
          lFreeElem(&dep_range);
          Depend = 1;
          break;
@@ -345,7 +346,6 @@
 
    if (lGetNumberOfElem(lGetList(jep, JB_ja_ad_request_list)) > 0) {
       if (lGetNumberOfElem(lGetList(jep, JB_ja_ad_predecessor_list)) == 0) {
-         DPRINTF(("all predecessors are gone (1)!\n")); 
          /* fast case where all predecessors are "gone" */         
          if (sge_task_depend_flush(jep, alpp))
             ret = true;
diff --exclude-from=/srv/pbuilder/result/sid/sge_ignore -Naur gridengine-6.2~beta2/source/daemons/qmaster/sge_thread_jvm.c gridengine-6.2/source/daemons/qmaster/sge_thread_jvm.c
--- gridengine-6.2~beta2/source/daemons/qmaster/sge_thread_jvm.c	2008-06-15 15:29:43.000000000 +0100
+++ gridengine-6.2/source/daemons/qmaster/sge_thread_jvm.c	2008-08-08 18:14:12.000000000 +0100
@@ -689,6 +689,7 @@
    lListElem *confEntry = NULL;
    const int fixed_jvm_argc = 16;
    bool ret = true;
+   char keystore_path[SGE_PATH_MAX];
 
    DENTER(TOP_LAYER, "sge_run_jvm");
 
@@ -707,6 +708,27 @@
    }  
 
    /*
+   ** get keystore property
+   */
+   {
+      #define NUM_PROPS 1
+      dstring error_dstring = DSTRING_INIT;
+      bootstrap_entry_t name[NUM_PROPS] = { {"com.sun.grid.jgdi.management.jmxremote.ssl.serverKeystore", true} };
+      char value[NUM_PROPS][SGE_PATH_MAX];
+
+      sge_dstring_sprintf(&ds, "%s/common/jmx/management.properties", ctx->get_cell_root(ctx));
+      DPRINTF(("++ management.properties: %s\n", sge_dstring_get_string(&ds)));
+      if (sge_get_management_entry(sge_dstring_get_string(&ds), NUM_PROPS, NUM_PROPS, name, 
+                                    value, &error_dstring)) {
+         WARNING((SGE_EVENT, "could not read keystore path %s\n", sge_dstring_get_string(&error_dstring)));
+         sge_dstring_free(&error_dstring);
+         DRETURN(false);
+      }
+      sge_strlcpy(keystore_path, value[0], SGE_PATH_MAX);
+      DPRINTF(("++ keystore_path: %s\n", keystore_path));
+   }
+   
+   /*
    ** get additional jvm args from configuration
    */
    confEntry = sge_get_configuration_entry_by_name(ctx->get_qualified_hostname(ctx), "additional_jvm_args");
@@ -742,7 +764,7 @@
    jvm_argv[0] = strdup(sge_dstring_sprintf(&ds, "-Dcom.sun.grid.jgdi.sgeRoot=%s", ctx->get_sge_root(ctx)));
    jvm_argv[1] = strdup(sge_dstring_sprintf(&ds, "-Dcom.sun.grid.jgdi.sgeCell=%s", ctx->get_default_cell(ctx)));
    jvm_argv[2] = strdup(sge_dstring_sprintf(&ds, "-Dcom.sun.grid.jgdi.caTop=%s", ctx->get_ca_root(ctx)));
-   jvm_argv[3] = strdup(sge_dstring_sprintf(&ds, "-Dcom.sun.grid.jgdi.serverKeystore=%s/private/keystore", ctx->get_ca_local_root(ctx)));
+   jvm_argv[3] = strdup(sge_dstring_sprintf(&ds, "-Dcom.sun.grid.jgdi.serverKeystore=%s", keystore_path));
    jvm_argv[4] = strdup(sge_dstring_sprintf(&ds, "-Dcom.sun.grid.jgdi.sgeQmasterSpoolDir=%s", ctx->get_qmaster_spool_dir(ctx)));
    jvm_argv[5] = strdup(sge_dstring_sprintf(&ds, "-Djava.class.path=%s/lib/jgdi.jar:%s/lib/juti.jar", ctx->get_sge_root(ctx), ctx->get_sge_root(ctx)));
    jvm_argv[6] = strdup(sge_dstring_sprintf(&ds, "-Djava.security.policy=%s/common/jmx/java.policy", ctx->get_cell_root(ctx)));
diff --exclude-from=/srv/pbuilder/result/sid/sge_ignore -Naur gridengine-6.2~beta2/source/daemons/qmaster/sge_userprj_qmaster.c gridengine-6.2/source/daemons/qmaster/sge_userprj_qmaster.c
--- gridengine-6.2~beta2/source/daemons/qmaster/sge_userprj_qmaster.c	2008-06-15 15:29:43.000000000 +0100
+++ gridengine-6.2/source/daemons/qmaster/sge_userprj_qmaster.c	2008-08-08 18:14:12.000000000 +0100
@@ -420,7 +420,7 @@
 
       /* check user list for reference */
       if ((prj = lGetElemStr(*object_base[SGE_TYPE_USER].list, UU_default_project, name))) {
-         ERROR((SGE_EVENT, MSG_USERPRJ_PRJXSTILLREFERENCEDINENTRYX_SS, name, lGetString(prj, PR_name)));
+         ERROR((SGE_EVENT, MSG_USERPRJ_PRJXSTILLREFERENCEDINENTRYX_SS, name, lGetString(prj, UU_name)));
          answer_list_add(alpp, SGE_EVENT, STATUS_EUNKNOWN, ANSWER_QUALITY_ERROR);
          DEXIT;
          return STATUS_EEXIST;
diff --exclude-from=/srv/pbuilder/result/sid/sge_ignore -Naur gridengine-6.2~beta2/source/daemons/shepherd/setrlimits.c gridengine-6.2/source/daemons/shepherd/setrlimits.c
--- gridengine-6.2~beta2/source/daemons/shepherd/setrlimits.c	2008-06-15 15:29:44.000000000 +0100
+++ gridengine-6.2/source/daemons/shepherd/setrlimits.c	2008-08-08 18:14:13.000000000 +0100
@@ -75,7 +75,7 @@
 #ifndef CRAY
 static void pushlimit(int, struct RLIMIT_STRUCT_TAG *, int trace_rlimit);
 
-static int get_resource_info(u_long32 resource, char **name, int *resource_type);
+static int get_resource_info(u_long32 resource, const char **name, int *resource_type);
 #endif
 
 static int rlimcmp(sge_rlim_t r1, sge_rlim_t r2);
@@ -130,7 +130,9 @@
 
 void setrlimits(int trace_rlimit) {
    sge_rlim_t s_cpu, h_cpu, s_core, h_core, s_data, h_data, 
-      s_fsize, h_fsize, s_stack, h_stack, s_vmem, h_vmem;
+      s_fsize, h_fsize, s_stack, h_stack, s_vmem, h_vmem,
+      s_descriptors, h_descriptors, s_maxproc, h_maxproc,
+      s_memorylocked, h_memorylocked, s_locks, h_locks;
 #if defined(NECSX4) || defined(NECSX5)
    sge_rlim_t s_tmpf, h_tmpf, s_mtdev, h_mtdev, s_nofile, h_nofile,
       s_proc, h_proc, s_rlg0, h_rlg0, s_rlg1, h_rlg1, s_rlg2, h_rlg2,
@@ -153,6 +155,14 @@
    s = get_conf_val(attr); \
    sge_parse_limit(dstp, s, error_str, sizeof(error_str));
 
+#define PARSE_IT_UNDEF(dstp, attr) \
+   s = get_conf_val(attr); \
+   if (!strncasecmp(s, "UNDEFINED", sizeof("UNDEFINED")-1)) { \
+      *dstp = RLIMIT_UNDEFINED; \
+   } else { \
+      sge_parse_limit(dstp, s, error_str, sizeof(error_str)); \
+   }
+
    PARSE_IT(&s_cpu, "s_cpu");
    PARSE_IT(&h_cpu, "h_cpu");
    PARSE_IT(&s_core, "s_core");
@@ -167,6 +177,14 @@
    PARSE_IT(&h_fsize, "h_fsize");
    PARSE_IT(&s_vmem, "s_vmem");
    PARSE_IT(&h_vmem, "h_vmem");
+   PARSE_IT_UNDEF(&s_descriptors, "s_descriptors");
+   PARSE_IT_UNDEF(&h_descriptors, "h_descriptors");
+   PARSE_IT_UNDEF(&s_maxproc,     "s_maxproc");
+   PARSE_IT_UNDEF(&h_maxproc,     "h_maxproc");
+   PARSE_IT_UNDEF(&s_memorylocked, "s_memorylocked");
+   PARSE_IT_UNDEF(&h_memorylocked, "h_memorylocked");
+   PARSE_IT_UNDEF(&s_locks,        "s_locks");
+   PARSE_IT_UNDEF(&h_locks,        "h_locks");
 #if defined(NECSX4) || defined(NECSX5)
    PARSE_IT(&s_tmpf, "s_tmpf");
    PARSE_IT(&h_tmpf, "h_tmpf");
@@ -190,22 +208,48 @@
 
 #define RL_MAX(r1, r2) ((rlimcmp((r1), (r2))>0)?(r1):(r2))
 #define RL_MIN(r1, r2) ((rlimcmp((r1), (r2))<0)?(r1):(r2))
-    /*
-     * we have to define some minimum limits to make sure that
-     * that the shepherd can run without trouble
-     */
-    s_vmem = RL_MAX(s_vmem, LIMIT_VMEM_MIN);
-    h_vmem = RL_MAX(h_vmem, LIMIT_VMEM_MIN);
-    s_data = RL_MAX(s_data, LIMIT_VMEM_MIN);
-    h_data = RL_MAX(h_data, LIMIT_VMEM_MIN);
-    s_rss = RL_MAX(s_rss, LIMIT_VMEM_MIN);
-    h_rss = RL_MAX(h_rss, LIMIT_VMEM_MIN);
-    s_stack = RL_MAX(s_stack, LIMIT_STACK_MIN);
-    h_stack = RL_MAX(h_stack, LIMIT_STACK_MIN);
-    s_cpu = RL_MAX(s_cpu, LIMIT_CPU_MIN);
-    h_cpu = RL_MAX(h_cpu, LIMIT_CPU_MIN);
-    s_fsize = RL_MAX(s_fsize, LIMIT_FSIZE_MIN);
-    h_fsize = RL_MAX(h_fsize, LIMIT_FSIZE_MIN);   
+   /*
+    * we have to define some minimum limits to make sure that
+    * that the shepherd can run without trouble
+    */
+   s_vmem = RL_MAX(s_vmem, LIMIT_VMEM_MIN);
+   h_vmem = RL_MAX(h_vmem, LIMIT_VMEM_MIN);
+   s_data = RL_MAX(s_data, LIMIT_VMEM_MIN);
+   h_data = RL_MAX(h_data, LIMIT_VMEM_MIN);
+   s_rss = RL_MAX(s_rss, LIMIT_VMEM_MIN);
+   h_rss = RL_MAX(h_rss, LIMIT_VMEM_MIN);
+   s_stack = RL_MAX(s_stack, LIMIT_STACK_MIN);
+   h_stack = RL_MAX(h_stack, LIMIT_STACK_MIN);
+   s_cpu = RL_MAX(s_cpu, LIMIT_CPU_MIN);
+   h_cpu = RL_MAX(h_cpu, LIMIT_CPU_MIN);
+   s_fsize = RL_MAX(s_fsize, LIMIT_FSIZE_MIN);
+   h_fsize = RL_MAX(h_fsize, LIMIT_FSIZE_MIN);
+   if (s_descriptors != RLIMIT_UNDEFINED) {
+      s_descriptors = RL_MAX(s_descriptors, LIMIT_DESCR_MIN);
+      s_descriptors = RL_MIN(s_descriptors, LIMIT_DESCR_MAX);
+   }
+   if (h_descriptors != RLIMIT_UNDEFINED) {
+      h_descriptors = RL_MAX(h_descriptors, LIMIT_DESCR_MIN);
+      s_descriptors = RL_MIN(s_descriptors, LIMIT_DESCR_MAX);
+   }
+   if (s_maxproc != RLIMIT_UNDEFINED) {
+      s_maxproc = RL_MAX(s_maxproc, LIMIT_PROC_MIN);
+   }
+   if (h_maxproc != RLIMIT_UNDEFINED) {
+      h_maxproc = RL_MAX(h_maxproc, LIMIT_PROC_MIN);
+   }
+   if (s_memorylocked != RLIMIT_UNDEFINED) {
+      s_memorylocked = RL_MAX(s_memorylocked, LIMIT_MEMLOCK_MIN);
+   }
+   if (h_memorylocked != RLIMIT_UNDEFINED) {
+      h_memorylocked = RL_MAX(h_memorylocked, LIMIT_MEMLOCK_MIN);
+   }
+   if (s_locks != RLIMIT_UNDEFINED) {
+      s_locks = RL_MAX(s_locks, LIMIT_LOCKS_MIN);
+   }
+   if (h_locks != RLIMIT_UNDEFINED) {
+      h_locks = RL_MAX(h_locks, LIMIT_LOCKS_MIN);
+   }
 
    /* 
     * s_vmem > h_vmem
@@ -242,6 +286,30 @@
    h_data = mul_infinity(h_data, host_slots);
    s_stack = mul_infinity(s_stack, host_slots);
    h_stack = mul_infinity(h_stack, host_slots);
+   if (s_descriptors != RLIMIT_UNDEFINED) {
+      s_descriptors = mul_infinity(s_descriptors, host_slots);
+   }
+   if (h_descriptors != RLIMIT_UNDEFINED) {
+      h_descriptors = mul_infinity(h_descriptors, host_slots);
+   }
+   if (s_maxproc != RLIMIT_UNDEFINED) {
+      s_maxproc = mul_infinity(s_maxproc, host_slots);
+   }
+   if (h_maxproc != RLIMIT_UNDEFINED) {
+      h_maxproc = mul_infinity(h_maxproc, host_slots);
+   }
+   if (s_memorylocked != RLIMIT_UNDEFINED) {
+      s_memorylocked = mul_infinity(s_memorylocked, host_slots);
+   }
+   if (h_memorylocked != RLIMIT_UNDEFINED) {
+      h_memorylocked = mul_infinity(h_memorylocked, host_slots);
+   }
+   if (s_locks != RLIMIT_UNDEFINED) {
+      s_locks = mul_infinity(s_locks, host_slots);
+   }
+   if (h_locks != RLIMIT_UNDEFINED) {
+      h_locks = mul_infinity(h_locks, host_slots);
+   }
 
 #if defined(CRAY)
 
@@ -285,6 +353,62 @@
    rlp.rlim_max = h_core;
    pushlimit(RLIMIT_CORE, &rlp, trace_rlimit);
 
+#  if defined(RLIMIT_NOFILE)
+   if (s_descriptors != RLIMIT_UNDEFINED && h_descriptors == RLIMIT_UNDEFINED) {
+      h_descriptors = s_descriptors;
+   }
+   if (h_descriptors != RLIMIT_UNDEFINED && s_descriptors == RLIMIT_UNDEFINED) {
+      s_descriptors = h_descriptors;
+   }
+   if (s_descriptors != RLIMIT_UNDEFINED && h_descriptors != RLIMIT_UNDEFINED) {
+      rlp.rlim_cur = s_descriptors;
+      rlp.rlim_max = h_descriptors;
+      pushlimit(RLIMIT_NOFILE, &rlp, trace_rlimit);
+   }
+#  endif
+
+#  if defined(RLIMIT_NPROC)
+   if (s_maxproc != RLIMIT_UNDEFINED && h_maxproc == RLIMIT_UNDEFINED) {
+      h_maxproc = s_maxproc;
+   }
+   if (h_maxproc != RLIMIT_UNDEFINED && s_maxproc == RLIMIT_UNDEFINED) {
+      s_maxproc = h_maxproc;
+   }
+   if (s_maxproc != RLIMIT_UNDEFINED && h_maxproc != RLIMIT_UNDEFINED) {
+      rlp.rlim_cur = s_maxproc;
+      rlp.rlim_max = h_maxproc;
+      pushlimit(RLIMIT_NPROC, &rlp, trace_rlimit);
+   }
+#  endif
+
+#  if defined(RLIMIT_MEMLOCK)
+   if (s_memorylocked != RLIMIT_UNDEFINED && h_memorylocked == RLIMIT_UNDEFINED) {
+      h_memorylocked = s_memorylocked;
+   }
+   if (h_memorylocked != RLIMIT_UNDEFINED && s_memorylocked == RLIMIT_UNDEFINED) {
+      s_memorylocked = h_memorylocked;
+   }
+   if (s_memorylocked != RLIMIT_UNDEFINED && h_memorylocked != RLIMIT_UNDEFINED) {
+      rlp.rlim_cur = s_memorylocked;
+      rlp.rlim_max = h_memorylocked;
+      pushlimit(RLIMIT_MEMLOCK, &rlp, trace_rlimit);
+   }
+# endif
+
+#  if defined(RLIMIT_LOCKS)
+   if (s_locks != RLIMIT_UNDEFINED && h_locks == RLIMIT_UNDEFINED) {
+      h_locks = s_locks;
+   }
+   if (h_locks != RLIMIT_UNDEFINED && s_locks == RLIMIT_UNDEFINED) {
+      s_locks = h_locks;
+   }
+   if (s_locks != RLIMIT_UNDEFINED && h_locks != RLIMIT_UNDEFINED) {
+      rlp.rlim_cur = s_locks;
+      rlp.rlim_max = h_locks;
+      pushlimit(RLIMIT_LOCKS, &rlp, trace_rlimit);
+   }
+#  endif
+
 #  if defined(RLIMIT_VMEM)
    rlp.rlim_cur = s_vmem;
    rlp.rlim_max = h_vmem;
@@ -335,45 +459,57 @@
 }
 
 #ifndef CRAY
-static int get_resource_info(u_long32 resource, char **name, 
-                             int *resource_type) 
-{
-   int is_job_resource_column;
-   int row;
-
-   /* *INDENT-OFF* */
-   /* resource           resource_name              resource_type
-                                                    NECSX 4/5
-                                                    |         OTHER ARCHS
-                                                    |         |          */
-   struct resource_table_entry resource_table[] = {
-      {RLIMIT_FSIZE,     "RLIMIT_FSIZE",            {RES_PROC, RES_PROC}},
-      {RLIMIT_DATA,      "RLIMIT_DATA",             {RES_PROC, RES_PROC}},
-      {RLIMIT_STACK,     "RLIMIT_STACK",            {RES_PROC, RES_PROC}},
-      {RLIMIT_CORE,      "RLIMIT_CORE",             {RES_PROC, RES_PROC}},
-      {RLIMIT_CPU,       "RLIMIT_CPU",              {RES_BOTH, RES_PROC}},
+/* *INDENT-OFF* */
+/* resource           resource_name              resource_type
+                                                 NECSX 4/5
+                                                 |         OTHER ARCHS
+                                                 |         |          */
+const struct resource_table_entry resource_table[] = {
+   {RLIMIT_FSIZE,     "RLIMIT_FSIZE",            {RES_PROC, RES_PROC}},
+   {RLIMIT_DATA,      "RLIMIT_DATA",             {RES_PROC, RES_PROC}},
+   {RLIMIT_STACK,     "RLIMIT_STACK",            {RES_PROC, RES_PROC}},
+   {RLIMIT_CORE,      "RLIMIT_CORE",             {RES_PROC, RES_PROC}},
+   {RLIMIT_CPU,       "RLIMIT_CPU",              {RES_BOTH, RES_PROC}},
+#if defined(RLIMIT_NPROC)
+   {RLIMIT_NPROC,     "RLIMIT_NPROC",            {RES_PROC, RES_PROC}},
+#endif
+#if defined(RLIMIT_MEMLOCK)
+   {RLIMIT_MEMLOCK,   "RLIMIT_MEMLOCK",          {RES_PROC, RES_PROC}},
+#endif
+#if defined(RLIMIT_LOCKS)
+   {RLIMIT_LOCKS,     "RLIMIT_LOCKS",            {RES_PROC, RES_PROC}},
+#endif
+#if defined(RLIMIT_NOFILE)
+   {RLIMIT_NOFILE,    "RLIMIT_NOFILE",           {RES_BOTH, RES_PROC}},
+#endif
 #if defined(RLIMIT_RSS)
-      {RLIMIT_RSS,       "RLIMIT_RSS",              {RES_PROC, RES_PROC}},
+   {RLIMIT_RSS,       "RLIMIT_RSS",              {RES_PROC, RES_PROC}},
 #endif
 #if defined(RLIMIT_VMEM)
-      {RLIMIT_VMEM,      "RLIMIT_VMEM",             {RES_PROC, RES_PROC}},
+   {RLIMIT_VMEM,      "RLIMIT_VMEM",             {RES_PROC, RES_PROC}},
 #elif defined(RLIMIT_AS)
-      {RLIMIT_AS,        "RLIMIT_VMEM/RLIMIT_AS",   {RES_PROC, RES_PROC}},
+   {RLIMIT_AS,        "RLIMIT_VMEM/RLIMIT_AS",   {RES_PROC, RES_PROC}},
 #endif
 #if defined(NECSX4) || defined(NECSX5)
-      {RLIMIT_TMPF,      "RLIMIT_TMPF",             {RES_JOB,  RES_PROC}},
-      {RLIMIT_MTDEV,     "RLIMIT_MTDEV",            {RES_JOB,  RES_PROC}},
-      {RLIMIT_NOFILE,    "RLIMIT_NOFILE",           {RES_BOTH, RES_PROC}},
-      {RLIMIT_PROC,      "RLIMIT_PROC",             {RES_JOB,  RES_PROC}},
-      {RLIMIT_RLG0,      "RLIMIT_RLG0",             {RES_JOB,  RES_PROC}},
-      {RLIMIT_RLG1,      "RLIMIT_RLG1",             {RES_JOB,  RES_PROC}},
-      {RLIMIT_RLG2,      "RLIMIT_RLG2",             {RES_JOB,  RES_PROC}},
-      {RLIMIT_RLG3,      "RLIMIT_RLG3",             {RES_JOB,  RES_PROC}},
-      {RLIMIT_CPURESTM,  "RLIMIT_CPURESTM",         {RES_JOB,  RES_PROC}},
-#endif
-      {0,                NULL,                      {0, 0}}
-   };
-   /* *INDENT-ON* */
+   {RLIMIT_TMPF,      "RLIMIT_TMPF",             {RES_JOB,  RES_PROC}},
+   {RLIMIT_MTDEV,     "RLIMIT_MTDEV",            {RES_JOB,  RES_PROC}},
+   {RLIMIT_PROC,      "RLIMIT_PROC",             {RES_JOB,  RES_PROC}},
+   {RLIMIT_RLG0,      "RLIMIT_RLG0",             {RES_JOB,  RES_PROC}},
+   {RLIMIT_RLG1,      "RLIMIT_RLG1",             {RES_JOB,  RES_PROC}},
+   {RLIMIT_RLG2,      "RLIMIT_RLG2",             {RES_JOB,  RES_PROC}},
+   {RLIMIT_RLG3,      "RLIMIT_RLG3",             {RES_JOB,  RES_PROC}},
+   {RLIMIT_CPURESTM,  "RLIMIT_CPURESTM",         {RES_JOB,  RES_PROC}},
+#endif
+   {0,                NULL,                      {0, 0}}
+};
+const char *unknown_string = "unknown";
+/* *INDENT-ON* */
+
+static int get_resource_info(u_long32 resource, const char **name, 
+                             int *resource_type) 
+{
+   int is_job_resource_column;
+   int row;
 
 #if defined(NECSX4) || defined(NECSX5)
    is_job_resource_column = 0;
@@ -391,7 +527,7 @@
       }
       row++;
    }
-   *name = "unknown";
+   *name = unknown_string;
    return 1;       
 }
 #endif
@@ -415,7 +551,7 @@
 static void pushlimit(int resource, struct RLIMIT_STRUCT_TAG *rlp, 
                       int trace_rlimit) 
 {
-   char *limit_str;
+   const char *limit_str;
    char trace_str[1024];
    struct RLIMIT_STRUCT_TAG dlp;
    int resource_type;
diff --exclude-from=/srv/pbuilder/result/sid/sge_ignore -Naur gridengine-6.2~beta2/source/daemons/shepherd/setrlimits.h gridengine-6.2/source/daemons/shepherd/setrlimits.h
--- gridengine-6.2~beta2/source/daemons/shepherd/setrlimits.h	2008-06-15 15:29:44.000000000 +0100
+++ gridengine-6.2/source/daemons/shepherd/setrlimits.h	2008-08-08 18:14:13.000000000 +0100
@@ -39,6 +39,11 @@
 #define LIMIT_STACK_MIN (1l*1024l*1024l)
 #define LIMIT_CPU_MIN (2l)
 #define LIMIT_FSIZE_MIN (15l*1024l)       
+#define LIMIT_DESCR_MIN (100)
+#define LIMIT_DESCR_MAX (65535)
+#define LIMIT_PROC_MIN  (20)
+#define LIMIT_MEMLOCK_MIN (4*1024)
+#define LIMIT_LOCKS_MIN (2)
 
 struct resource_table_entry {
    int resource;
diff --exclude-from=/srv/pbuilder/result/sid/sge_ignore -Naur gridengine-6.2~beta2/source/daemons/shepherd/sge_shepherd_ijs.c gridengine-6.2/source/daemons/shepherd/sge_shepherd_ijs.c
--- gridengine-6.2~beta2/source/daemons/shepherd/sge_shepherd_ijs.c	2008-06-15 15:29:44.000000000 +0100
+++ gridengine-6.2/source/daemons/shepherd/sge_shepherd_ijs.c	2008-08-08 18:14:13.000000000 +0100
@@ -69,65 +69,117 @@
 #include "sge_fileio.h"
 #include "sge_uidgid.h"
 #include "sge_unistd.h"
+#include "sge_signal.h"
 
 #define RESPONSE_MSG_TIMEOUT 120
 
-#define COMM_SERVER "qrsh"
-#define COMM_CLIENT "shepherd"
-
-/* copy from shepherd.c */
-#define CKPT_REST_KERNEL 0x080     /* set for all restarted kernel ckpt jobs */
-/* end copy from shepherd.c */
+#define COMM_SERVER "qrsh_ijs"
+#define COMM_CLIENT "shepherd_ijs"
 
 /* 
- * Compile with EXTENSIVE_TRACING defined to get lots of trace messages form
+ * Compile with EXTENSIVE_TRACING defined to get lots of trace messages from
  * the two worker threads.
  */
 #undef EXTENSIVE_TRACING
+/*#define EXTENSIVE_TRACING*/
 
-extern int received_signal;
-
-int my_error_printf(const char *fmt, ...);
-
-static int                  g_ptym           = -1;
-static int                  g_fd_pipe_in[2]  = {-1,-1};
-static int                  g_fd_pipe_out[2] = {-1, -1};
-static int                  g_fd_pipe_err[2] = {-1, -1};
+static int                  g_ptym                = -1;
+static int                  g_fd_pipe_in[2]       = {-1,-1};
+static int                  g_fd_pipe_out[2]      = {-1, -1};
+static int                  g_fd_pipe_err[2]      = {-1, -1};
 static int                  g_fd_pipe_to_child[2] = {-1, -1};
-static COMMUNICATION_HANDLE *g_comm_handle   = NULL;
+static COMMUNICATION_HANDLE *g_comm_handle        = NULL;
 static THREAD_HANDLE        g_thread_main;
-static int                  g_ckpt_pid            = 0;
-static int                  g_ckpt_type           = 0;
-static int                  g_timeout             = 0;
-static int                  g_ckpt_interval       = 0;
-static char                 *g_childname          = NULL;
 static int                  g_raised_event        = 0;
-static struct rusage        *g_rusage             = NULL;
-static int                  *g_exit_status        = NULL;
 static int                  g_job_pid             = 0;
 
 char                        *g_hostname           = NULL;
-extern bool                 g_csp_mode;  /* defined in shepherd.c */
+extern bool                 g_csp_mode;      /* defined in shepherd.c */
+extern int                  received_signal; /* defined in shepherd.c */
+
+/*
+ * Forward declarations of functions from shepherd.c
+ */
+int wait_my_child(
+int pid,                   /* pid of job */
+int ckpt_pid,              /* pid of restarted job or same as pid */
+int ckpt_type,             /* type of checkpointing */
+struct rusage *rusage,     /* accounting information */
+int timeout,               /* used for prolog/epilog script, 0 for job */
+int ckpt_interval,         /* action depend on ckpt_type */
+char *childname            /* "job", "pe_start", ...     */
+);
 
-void handle_signals_and_methods(
-   int npid,
-   int pid,
-   int *postponed_signal,
-   pid_t ctrl_pid[3],
-   int ckpt_interval,
-   int ckpt_type,
-   int *ckpt_cmd_pid,
-   int *rest_ckpt_interval,
-   int timeout,
-   int *migr_cmd_pid,
-   int ckpt_pid,
-   int *kill_job_after_checkpoint,
-   int status,
-   int *inArena,
-   int *inCkpt,
-   char *childname,
-   int *job_status,
-   int *job_pid);
+void 
+shepherd_signal_job(pid_t pid, int sig);
+
+/*
+ * static functions 
+ */
+/****** trace_buf() **********************************************************
+*  NAME
+*     trace_buf() -- writes contents of a buffer partially to the trace file
+*
+*  SYNOPSIS
+*     int trace_buf(const char *buffer, int length, const char *format, ...)
+*
+*  FUNCTION
+*     Writes the contents of a buffer, preceeded by a formatted string,
+*     partially to the trace file. I.e. it first writes the formatted
+*     string to the trace file, replacing the printf placeholders with
+*     the variables provided in ..., and then adds the first 99 or "length" 
+*     characters (which ever is smaller), encapsulated by hyphens, to
+*     the formatted string.
+*
+*  INPUTS
+*     const char *buffer - the buffer that is to be written to the trace file
+*     int        length  - length of the content of the buffer
+*     const char *format - 
+*     int  fd          - file descriptor to read from
+*     char *pbuf       - working buffer, must be of size BUFSIZE
+*     int  *buf_bytes  - number of bytes already in the buffer
+*
+*  OUTPUTS
+*     int *buf_bytes   - number of bytes in the buffer
+*
+*  RESULT
+*     int - >0: OK, number of bytes read from the fd
+*           =0: EINTR or EAGAIN occured, just call select() and read again
+*           -1: error occcured, connection was closed
+*
+*  NOTES
+*     MT-NOTE: 
+*
+*  SEE ALSO
+*******************************************************************************/
+#ifdef EXTENSIVE_TRACING
+static int trace_buf(const char *buffer, int length, const char *format, ...)
+{
+   int         ret;
+   va_list     ap;
+   dstring     message = DSTRING_INIT;
+   char        tmpbuf[100];
+
+   if (length > 0) {
+      snprintf(tmpbuf, MIN(99,length), "%s", buffer);
+   } else {
+      strcpy(tmpbuf, "");
+   }
+
+   va_start(ap, format);
+   
+   sge_dstring_vsprintf(&message, format, ap);
+   sge_dstring_append(&message, "\"");
+   sge_dstring_append(&message, tmpbuf);
+   sge_dstring_append(&message, "\"");
+   ret = shepherd_trace("%s", sge_dstring_get_string(&message));
+
+   sge_dstring_free(&message);
+   va_end(ap);
+
+   return ret;
+}
+#endif
 
 /****** append_to_buf() ******************************************************
 *  NAME
@@ -157,7 +209,7 @@
 *
 *  SEE ALSO
 *******************************************************************************/
-int append_to_buf(int fd, char *pbuf, int *buf_bytes)
+static int append_to_buf(int fd, char *pbuf, int *buf_bytes)
 {
    int nread = 0;
 
@@ -203,7 +255,7 @@
 *
 *  SEE ALSO
 *******************************************************************************/
-int send_buf(char *pbuf, int buf_bytes, int message_type)
+static int send_buf(char *pbuf, int buf_bytes, int message_type)
 {
    int ret = 0;
    dstring err_msg = DSTRING_INIT;
@@ -258,17 +310,6 @@
    char                 *stderr_buf = NULL;
    int                  stdout_bytes = 0;
    int                  stderr_bytes = 0;
-   int                  postponed_signal = 0;
-   pid_t                ctrl_pid[3];
-   int                  ckpt_cmd_pid = -999;
-   int                  migr_cmd_pid = -999;
-   int                  rest_ckpt_interval = g_ckpt_interval;
-   int                  kill_job_after_checkpoint = 0;
-   int                  status = 0;
-   int                  inArena, inCkpt = 0;
-   int                  job_id = 0;
-   int                  i;
-   int                  npid;
    bool                 b_select_timeout = false;
    dstring              err_msg = DSTRING_INIT;
 
@@ -281,75 +322,11 @@
    stdout_buf = sge_malloc(BUFSIZE);
    stderr_buf = sge_malloc(BUFSIZE);
 
-   /* Write info that we already have a checkpoint in the arena */
-   if (g_ckpt_type & CKPT_REST_KERNEL) {
-      inArena = 1;
-      create_checkpointed_file(1);
-   } else {
-      inArena = 0;
-   }
-
-   /* Initialize some variables */
-   for (i=0; i<3; i++) {
-      ctrl_pid[i] = -999;
-   }
-   memset(g_rusage, 0, sizeof(*g_rusage));
-
    /* The main loop of this thread */
    while (do_exit == 0) {
-      /* If a signal was received, process it */
-#ifdef EXTENSIVE_TRACING
-      shepherd_trace("pty_to_commlib: calling wait3() to check if a child process exited.");
-#endif
-#if defined(CRAY) || defined(NECSX4) || defined(NECSX5) || defined(INTERIX)
-      npid = waitpid(-1, &status, WNOHANG);
-#else
-      npid = wait3(&status, WNOHANG, g_rusage);
-#endif
-#ifdef EXTENSIVE_TRACING
-      shepherd_trace("pty_to_commlib: wait3() returned npid = %d, status = %d, "
-                     "errno = %d, %s.", status, npid, errno, strerror(errno));
-      shepherd_trace("pty_to_commlib: received_signal = %d", received_signal);
-#endif
-
-      /* We always want to handle signals and methods, so we set npid = -1
-       * - except when wait3() returned a valid pid.
-       */
-      if (npid > 0) {
-         shepherd_trace("pty_to_commlib: our child exited -> exiting");
-         do_exit = 1;
-      }
-      if (npid == 0) {
-         npid = -1;
-      }
-
-      /* Do all the handling for signals, checkpointing and migrating and methods. */
-      handle_signals_and_methods(
-         npid,
-         g_job_pid,
-         &postponed_signal,
-         ctrl_pid,
-         g_ckpt_interval,
-         g_ckpt_type,
-         &ckpt_cmd_pid,
-         &rest_ckpt_interval,
-         g_timeout,
-         &migr_cmd_pid,
-         g_ckpt_pid,
-         &kill_job_after_checkpoint,
-         status,
-         &inArena,
-         &inCkpt,
-         g_childname,
-         g_exit_status,
-         &job_id);
-
       /* Fill fd_set for select */
       FD_ZERO(&read_fds);
-      /* Do this only if commlib doesn't have many messages to send in it's
-       * queue. Otherwise, don't read from pty and don't send to commlib.
-       */
-      comm_trigger(g_comm_handle, 0, &err_msg);
+
       if (g_ptym != -1) {
          FD_SET(g_ptym, &read_fds);
       }
@@ -450,6 +427,10 @@
             shepherd_trace("pty_to_commlib: reading from ptym");
 #endif
             ret = append_to_buf(g_ptym, stdout_buf, &stdout_bytes);
+#ifdef EXTENSIVE_TRACING
+            trace_buf(stdout_buf, ret, "pty_to_commlib: appended %d bytes, stdout_buf = ", 
+                      ret, stdout_buf);
+#endif
          }
          if (ret >= 0 && g_fd_pipe_out[0] != -1
              && FD_ISSET(g_fd_pipe_out[0], &read_fds)) {
@@ -457,6 +438,11 @@
             shepherd_trace("pty_to_commlib: reading from pipe_out");
 #endif
             ret = append_to_buf(g_fd_pipe_out[0], stdout_buf, &stdout_bytes);
+
+#ifdef EXTENSIVE_TRACING
+            trace_buf(stdout_buf, ret, "pty_to_commlib: appended %d bytes, stdout_buf = ",
+                      ret, stdout_buf);
+#endif
          }
          if (ret >= 0 && g_fd_pipe_err[0] != -1
              && FD_ISSET(g_fd_pipe_err[0], &read_fds)) {
@@ -464,10 +450,11 @@
             shepherd_trace("pty_to_commlib: reading from pipe_err");
 #endif
             ret = append_to_buf(g_fd_pipe_err[0], stderr_buf, &stderr_bytes);
-         }
 #ifdef EXTENSIVE_TRACING
-         shepherd_trace("pty_to_commlib: appended %d bytes to buffer", ret);
+            trace_buf(stderr_buf, ret, "pty_to_commlib: appended %d bytes, stderr_buf = ",
+                      ret, stderr_buf);
 #endif
+         }
          if (ret < 0) {
             /* A fd was closed, likely our child has exited, we can exit, too. */
             shepherd_trace("pty_to_commlib: append_to_buf() returned %d, "
@@ -523,7 +510,7 @@
    sge_dstring_free(&err_msg);
 
 #ifdef EXTENSIVE_TRACING
-   shepherd_trace("pty_to_commlib: leaving commlib_to_pty thread");
+   shepherd_trace("pty_to_commlib: leaving pty_to_commlib thread");
 #endif
    return NULL;
 }
@@ -573,6 +560,8 @@
       shepherd_trace("commlib_to_pty: no valid handle for stdin available. Exiting!");
    }
 
+   cl_com_set_synchron_receive_timeout(g_comm_handle, 1);
+
    while (do_exit == 0) {
       /* wait blocking for a message from commlib */
       recv_mess.cl_message = NULL;
@@ -580,11 +569,7 @@
       sge_dstring_free(&err_msg);
       sge_dstring_sprintf(&err_msg, "");
 
-#ifdef EXTENSIVE_TRACING
-      shepherd_trace("commlib_to_pty: waiting in commlib_trigger() for data");
-#endif
-      ret = cl_commlib_trigger(g_comm_handle, 1);
-      ret = comm_recv_message(g_comm_handle, CL_FALSE, &recv_mess, &err_msg);
+      ret = comm_recv_message(g_comm_handle, CL_TRUE, &recv_mess, &err_msg);
 
       /* 
        * Check if the thread was cancelled. Exit thread if it was.
@@ -597,7 +582,6 @@
          do_exit = 1;
          continue;
       }
-
 #ifdef EXTENSIVE_TRACING
       shepherd_trace("commlib_to_pty: comm_recv_message() returned %d, err_msg: %s",
                      ret, sge_dstring_get_string(&err_msg));
@@ -634,8 +618,11 @@
                         b_sent_to_child = true;
                      }
                   }
-                  do_exit = 1;
+               } else {
+                  shepherd_trace("commlib_to_pty: was connected and still have "
+                                 "selectors, but lost connection -> exiting");
                }
+               do_exit = 1;
                break;
             case COMM_INVALID_PARAMETER:
                shepherd_trace("commlib_to_pty: communication handle or "
@@ -683,7 +670,7 @@
                b_was_connected = 1;
                break;
          }
-      } else {  /* if (ret == COMM_RETVAL_OK) { */
+      } else {  /* if (ret == COMM_RETVAL_OK) */
          /* We received a message, 'parse' it */
          switch (recv_mess.type) {
             case STDIN_DATA_MSG:
@@ -737,6 +724,15 @@
       }
       comm_free_message(&recv_mess, &err_msg);
    }
+   /*
+    * When we get here, likely the commlib connection was shut down
+    * from the other side. We have to kill the job here to wake up
+    * the main thread.
+    */
+   /* 
+    * TODO: Use SIGINT if qrsh client was quit with Ctrl-C
+    */
+   shepherd_signal_job(g_job_pid, SIGKILL);
 
    sge_dstring_free(&err_msg);
 
@@ -745,13 +741,11 @@
 #endif
    thread_func_cleanup(t_conf);
 /* TODO: pthread_condition, see other thread*/
-
 #ifdef EXTENSIVE_TRACING
    shepherd_trace("commlib_to_pty: raising event for main thread");
 #endif
    g_raised_event = 3;
    thread_trigger_event(&g_thread_main);
-
 #ifdef EXTENSIVE_TRACING
    shepherd_trace("commlib_to_pty: leaving commlib_to_pty thread");
 #endif
@@ -771,7 +765,8 @@
    THREAD_HANDLE     *thread_pty_to_commlib = NULL;
    THREAD_HANDLE     *thread_commlib_to_pty = NULL;
    cl_raw_list_t     *cl_com_log_list = NULL;
-   int               oldeuid = SGE_SUPERUSER_UID;
+
+   shepherd_trace("main: starting parent_loop");
 
    g_hostname            = strdup(hostname);
    g_ptym                = ptym;
@@ -783,24 +778,19 @@
    g_fd_pipe_err[1]      = fd_pipe_err[1];
    g_fd_pipe_to_child[0] = fd_pipe_to_child[0];
    g_fd_pipe_to_child[1] = fd_pipe_to_child[1];
-   g_ckpt_pid            = ckpt_pid;
-   g_ckpt_type           = ckpt_type;
-   g_timeout             = timeout;
-   g_ckpt_interval       = ckpt_interval;
-   g_childname           = childname;
-   g_rusage              = rusage;
-   g_exit_status         = exit_status;
    g_job_pid             = job_pid;
 
-   memset(g_rusage, 0, sizeof(*g_rusage));
-
-   shepherd_trace("main: starting parent_loop");
+   /*
+    * Initialize err_msg, so it's never NULL.
+    */
+   sge_dstring_sprintf(err_msg, "");
 
    ret = comm_init_lib(err_msg);
    if (ret != 0) {
       shepherd_trace("main: can't open communication library");
       return 1;
    }
+
    /*
     * Get log list of communication before a connection is opened.
     */
@@ -810,12 +800,11 @@
     * Open the connection port so we can connect to our server
     */
    shepherd_trace("main: opening connection to qrsh/qlogin client");
-   ret = comm_open_connection(false, port, COMM_CLIENT, g_csp_mode, user_name,
-                              &g_comm_handle, err_msg);
+   ret = comm_open_connection(false, g_csp_mode, COMM_CLIENT, port, COMM_SERVER,
+                              user_name, &g_comm_handle, err_msg);
    if (ret != COMM_RETVAL_OK) {
       shepherd_trace("main: can't open commlib stream, err_msg = %s", 
-                     sge_dstring_get_string(err_msg) != NULL ? 
-                     sge_dstring_get_string(err_msg): "<null>");
+                     sge_dstring_get_string(err_msg));
       return 1;
    }
 
@@ -825,15 +814,8 @@
     * commlib_to_pty thread.
     */
    shepherd_trace("main: sending REGISTER_CTRL_MSG");
-   if (getuid() == SGE_SUPERUSER_UID) {
-      oldeuid = geteuid();
-      seteuid(SGE_SUPERUSER_UID);
-   }
    ret = (int)comm_write_message(g_comm_handle, g_hostname, COMM_SERVER, 1, 
                       (unsigned char*)" ", 1, REGISTER_CTRL_MSG, err_msg);
-   if (oldeuid != SGE_SUPERUSER_UID) {
-      seteuid(oldeuid);
-   }
    if (ret == 0) {
       /* No bytes written - error */
       shepherd_trace("main: can't send REGISTER_CTRL_MSG, comm_write_message() "
@@ -845,49 +827,81 @@
     */
    /*   return 1;*/
    }
-
+#ifdef EXTENSIVE_TRACING
+   else {
+      shepherd_trace("main: Sent %d bytes to qrsh client", ret);
+   }
+#endif
    /*
-    * Setup thread list, setup this main thread so it can be triggered
-    * and create two worker threads
+    * Setup thread list.
     */
    ret = thread_init_lib(&thread_lib_handle);
 
    /* 
-    * Tell the thread library that there is a main thread running
-    * that can receive events.
+    * Register this main thread at the thread library, so it can
+    * be triggered and create two worker threads.
     */
    ret = register_thread(thread_lib_handle, &g_thread_main, "main thread");
    if (ret != CL_RETVAL_OK) {
       shepherd_trace("main: registering main thread failed: %d", ret);
       return 1;
    }
-   ret = create_thread(thread_lib_handle,
-                       &thread_pty_to_commlib,
-                       cl_com_log_list,
-                       "pty_to_commlib thread",
-                       2,
-                       pty_to_commlib);
-   if (ret != CL_RETVAL_OK) {
-      shepherd_trace("main: creating pty_to_commlib thread failed: %d", ret);
+
+   {
+      sigset_t old_sigmask;
+      sge_thread_block_all_signals(&old_sigmask);
+
+      ret = create_thread(thread_lib_handle,
+                          &thread_pty_to_commlib,
+                          cl_com_log_list,
+                          "pty_to_commlib thread",
+                          2,
+                          pty_to_commlib);
+      if (ret != CL_RETVAL_OK) {
+         shepherd_trace("main: creating pty_to_commlib thread failed: %d", ret);
+      }
+
+      ret = create_thread(thread_lib_handle,
+                          &thread_commlib_to_pty,
+                          cl_com_log_list,
+                          "commlib_to_pty thread",
+                          3,
+                          commlib_to_pty);
+
+      pthread_sigmask(SIG_SETMASK, &old_sigmask, NULL);
    }
 
-   ret = create_thread(thread_lib_handle,
-                       &thread_commlib_to_pty,
-                       cl_com_log_list,
-                       "commlib_to_pty thread",
-                       3,
-                       commlib_to_pty);
    if (ret != CL_RETVAL_OK) {
       shepherd_trace("main: creating commlib_to_pty thread failed: %d", ret);
    }
+
    /* From here on, the two worker threads are doing all the work.
     * This main thread is just waiting until one of the to worker threads
     * wants to exit and sends an event to the main thread.
     * A worker thread wants to exit when either the communciation to
     * the server was shut down or the user application (likely the shell)
     * exited.
+    * On some architectures, this thread awakens from the wait whenever
+    * a signal arrives. Therefore we have to check if it was a signal
+    * or a event that awoke this thread.
+    */
+   shepherd_trace("main: created both worker threads, now waiting jobs end");
+
+   *exit_status = wait_my_child(job_pid, ckpt_pid, ckpt_type, rusage, timeout,
+                 ckpt_interval, childname);
+   alarm(0);
+
+   shepherd_trace("main: wait_my_child returned exit_status = %d", *exit_status);
+   shepherd_trace("main:            rusage.ru_stime.tv_sec  = %d", rusage->ru_stime.tv_sec);
+   shepherd_trace("main:            rusage.ru_stime.tv_usec = %d", rusage->ru_stime.tv_usec);
+   shepherd_trace("main:            rusage.ru_utime.tv_sec  = %d", rusage->ru_utime.tv_sec);
+   shepherd_trace("main:            rusage.ru_utime.tv_usec = %d", rusage->ru_utime.tv_usec);
+
+   /*
+    * We are sure the job exited when we get here, but there could still be
+    * some output in the buffers, so wait for the communication threads
+    * to give them time to read, transmit and flush the buffers.
     */
-   shepherd_trace("main: created both worker threads, now waiting for event");
    while (g_raised_event == 0) {
       ret = thread_wait_for_event(&g_thread_main, 0, 0);
    }
@@ -953,32 +967,6 @@
    return 0;
 }
 
-int get_job_status(int job_pid, int *exit_status, struct rusage *usage)
-{
-   int npid;
-   int status;
-   struct rusage tmp_usage;
-
-   memset(&tmp_usage, 0, sizeof(tmp_usage));
-
-#if defined(CRAY) || defined(NECSX4) || defined(NECSX5) || defined(INTERIX)
-   npid = waitpid(-1, &status, 0);
-#else
-   npid = wait3(&status, 0, &tmp_usage);
-#endif
-   shepherd_trace("wait3() returned status = %d, npid = %d", status, npid);
-
-   if (npid == -1) {
-      shepherd_trace("npid == -1, errno = %d, %s", errno, strerror(errno));
-   }
-
-   if ((npid == job_pid) && ((WIFSIGNALED(status) || WIFEXITED(status)))) {
-      memcpy(usage, &tmp_usage, sizeof(tmp_usage));
-      *exit_status = status;
-      return 1;
-   }
-   return 0;
-}
 int close_parent_loop(int exit_status)
 {
    int     ret = 0;
@@ -1013,11 +1001,26 @@
 
       shepherd_trace("waiting for UNREGISTER_RESPONSE_CTRL_MSG");
       while (count < RESPONSE_MSG_TIMEOUT) {
+#if defined(INTERIX)
+/*
+ * TODO: comm_recv_message() should return immediatley when the server
+ *       is not running any more. On Interix, it waits until a timeout
+ *       occurs (60s), so we check if the server is running before
+ *       we wait for the message.
+ *       This has to be fixed in comm_recv_message() or the commlib.
+ */
+         if (check_client_alive(g_comm_handle, 
+                                COMM_SERVER, &err_msg) != COMM_RETVAL_OK) {
+            shepherd_trace("Server already exited");
+            break;
+         }
+#endif
          ret = comm_recv_message(g_comm_handle, CL_TRUE, &recv_mess, &err_msg);
          if (ret == COMM_GOT_TIMEOUT) {
             count++;
          } else if (recv_mess.type == UNREGISTER_RESPONSE_CTRL_MSG) {
             shepherd_trace("Received UNREGISTER_RESPONSE_CTRL_MSG");
+            comm_free_message(&recv_mess, &err_msg);
             break;
          } else {
             shepherd_trace("No connection or timeout while waiting for message");
@@ -1048,6 +1051,7 @@
 
    FREE(g_hostname);
    sge_dstring_free(&err_msg);
+   shepherd_trace("main: leaving closinge_parent_loop()");
    return 0;
 }
 
diff --exclude-from=/srv/pbuilder/result/sid/sge_ignore -Naur gridengine-6.2~beta2/source/daemons/shepherd/sge_shepherd_ijs.h gridengine-6.2/source/daemons/shepherd/sge_shepherd_ijs.h
--- gridengine-6.2~beta2/source/daemons/shepherd/sge_shepherd_ijs.h	2008-06-15 15:29:44.000000000 +0100
+++ gridengine-6.2/source/daemons/shepherd/sge_shepherd_ijs.h	2008-08-08 18:14:13.000000000 +0100
@@ -38,6 +38,4 @@
                 char *user_name, int *exit_status, 
                 struct rusage *rusage, int job_pid, dstring *err_msg);
  
-
-int get_job_status(int job_pid, int *exit_status, struct rusage *usage);
 int close_parent_loop(int exit_status);
diff --exclude-from=/srv/pbuilder/result/sid/sge_ignore -Naur gridengine-6.2~beta2/source/daemons/shepherd/shepherd.c gridengine-6.2/source/daemons/shepherd/shepherd.c
--- gridengine-6.2~beta2/source/daemons/shepherd/shepherd.c	2008-06-15 15:29:44.000000000 +0100
+++ gridengine-6.2/source/daemons/shepherd/shepherd.c	2008-08-08 18:14:13.000000000 +0100
@@ -159,7 +159,7 @@
 static void forward_signal_to_job(int pid, int timeout, int *postponed_signal, 
                        int remaining_alarm, pid_t ctrl_pid[3]);
 static int check_ckpttype(void);
-static int wait_my_child(int pid, int ckpt_pid, int ckpt_type, 
+int wait_my_child(int pid, int ckpt_pid, int ckpt_type, 
                          struct rusage *rusage, int timeout, 
                          int ckpt_interval, char *childname);
 static void set_ckpt_params(int, char *, int, char *, int, char *, int, int *);
@@ -177,7 +177,7 @@
 
 /* overridable control methods */
 static void verify_method(char *method_name);
-static void shepherd_signal_job(pid_t pid, int sig);
+void shepherd_signal_job(pid_t pid, int sig);
 
 char shepherd_job_dir[2048];
 
@@ -1225,14 +1225,6 @@
       kill(-pid, SIGKILL);
       sge_switch2admin_user();
 
-      if (exit_status == -1) {
-         exit_status = 0;
-         if (get_job_status(pid, &exit_status, &rusage) == 1) {
-            shepherd_trace("%s exited with exit status %d", 
-                           childname, WEXITSTATUS(exit_status));
-         }
-      }
-
       status = exit_status;
       ckpt_interval = 0;
 
@@ -2190,7 +2182,7 @@
    }   
 }         
 /*------------------------------------------------------------------------*/
-static int wait_my_child(
+int wait_my_child(
 int pid,                   /* pid of job */
 int ckpt_pid,              /* pid of restarted job or same as pid */
 int ckpt_type,             /* type of checkpointing */
@@ -2573,7 +2565,7 @@
  and uses it instead of the pid. If reading or killing fails, the normal
  mechanism is used.
  ****************************************************************/
-static void 
+void 
 shepherd_signal_job(pid_t pid, int sig) {
 #if defined(IRIX) || defined(CRAY) || defined(NECSX4) || defined(NECSX5)
    static int first = 1;
diff --exclude-from=/srv/pbuilder/result/sid/sge_ignore -Naur gridengine-6.2~beta2/source/libs/comm/cl_commlib.c gridengine-6.2/source/libs/comm/cl_commlib.c
--- gridengine-6.2~beta2/source/libs/comm/cl_commlib.c	2008-06-15 15:29:54.000000000 +0100
+++ gridengine-6.2/source/libs/comm/cl_commlib.c	2008-08-08 18:14:27.000000000 +0100
@@ -39,6 +39,7 @@
 #include <errno.h>
 #include "sge_arch.h"
 #include "sge_string.h"
+#include "sge_signal.h"
 
 
 #include "cl_commlib.h"
@@ -301,7 +302,7 @@
 #undef __CL_FUNCTION__
 #endif
 #define __CL_FUNCTION__ "cl_com_get_parameter_list_value()"
-int cl_com_get_parameter_list_value(char* parameter, char** value) {
+int cl_com_get_parameter_list_value(const char* parameter, char** value) {
    cl_parameter_list_elem_t* elem = NULL;
    int retval = CL_RETVAL_UNKNOWN_PARAMETER;
 
@@ -352,7 +353,7 @@
 #undef __CL_FUNCTION__
 #endif
 #define __CL_FUNCTION__ "cl_com_set_parameter_list_value()"
-int cl_com_set_parameter_list_value(char* parameter, char* value) {
+int cl_com_set_parameter_list_value(const char* parameter, char* value) {
    cl_parameter_list_elem_t* elem = NULL;
    int retval = CL_RETVAL_UNKNOWN_PARAMETER;
 
@@ -392,7 +393,7 @@
 #undef __CL_FUNCTION__
 #endif
 #define __CL_FUNCTION__ "cl_com_remove_parameter_list_value()"
-int cl_com_remove_parameter_list_value(char* parameter) {
+int cl_com_remove_parameter_list_value(const char* parameter) {
    int retval = CL_RETVAL_OK;
    pthread_mutex_lock(&cl_com_parameter_list_mutex);
    retval = cl_parameter_list_remove_parameter(cl_com_parameter_list, parameter,1);
@@ -429,7 +430,7 @@
          if (sub_token2 != NULL) {    
             if (strstr(sub_token1, "gdi_timeout") || strstr(sub_token1, "gdi_retries")) {
                if (sge_str_is_number(sub_token2)) {
-                  cl_com_set_parameter_list_value(sub_token1, sub_token2);
+                  cl_com_set_parameter_list_value((const char*)sub_token1, sub_token2);
                }
             } else {
                if (strstr(sub_token1, "cl_ping")) {
@@ -437,7 +438,7 @@
                        strlen(sub_token2) == sizeof("true")-1) || 
                       ((strncasecmp(sub_token2, "false", sizeof("false")-1) == 0) && 
                        strlen(sub_token2) == sizeof("false")-1)){
-                     cl_com_set_parameter_list_value(sub_token1, sub_token2);
+                     cl_com_set_parameter_list_value((const char*)sub_token1, sub_token2);
                   }
                }
             }
@@ -786,10 +787,18 @@
                return ret_val;
             }
             CL_LOG(CL_LOG_INFO,"starting trigger thread ...");
+
+            {
+            sigset_t old_sigmask;
+            sge_thread_block_all_signals(&old_sigmask);
+
             ret_val = cl_thread_list_create_thread(cl_com_thread_list,
                                                    &thread_p,
                                                    cl_com_log_list,
                                                    "trigger_thread", 1, cl_com_trigger_thread, NULL, NULL);
+            pthread_sigmask(SIG_SETMASK, &old_sigmask, NULL);
+            }
+
             if (ret_val != CL_RETVAL_OK) {
                pthread_mutex_unlock(&cl_com_thread_list_mutex);
                CL_LOG(CL_LOG_ERROR,"could not start trigger_thread");
@@ -1583,10 +1592,18 @@
 
          CL_LOG(CL_LOG_INFO,"starting handle service thread ...");
          snprintf(help_buffer,80,"%s_service",new_handle->local->comp_name);
+         {
+         sigset_t old_sigmask;
+         sge_thread_block_all_signals(&old_sigmask);
+
          return_value = cl_thread_list_create_thread(cl_com_thread_list,
                                                      &(new_handle->service_thread),
                                                      cl_com_log_list,
                                                      help_buffer, 2, cl_com_handle_service_thread, NULL, (void*)new_handle);
+
+         pthread_sigmask(SIG_SETMASK, &old_sigmask, NULL);
+         }
+
          if (return_value != CL_RETVAL_OK) {
             CL_LOG(CL_LOG_ERROR,"could not start handle service thread");
             thread_start_error = 1;
@@ -1595,10 +1612,19 @@
 
          CL_LOG(CL_LOG_INFO,"starting handle read thread ...");
          snprintf(help_buffer,80,"%s_read",new_handle->local->comp_name);
+
+         {
+         sigset_t old_sigmask;
+         sge_thread_block_all_signals(&old_sigmask);
+
          return_value = cl_thread_list_create_thread(cl_com_thread_list,
                                                      &(new_handle->read_thread),
                                                      cl_com_log_list,
                                                      help_buffer, 3, cl_com_handle_read_thread, NULL, NULL);
+
+         pthread_sigmask(SIG_SETMASK, &old_sigmask, NULL);
+         }
+
          if (return_value != CL_RETVAL_OK) {
             CL_LOG(CL_LOG_ERROR,"could not start handle read thread");
             thread_start_error = 1;
@@ -1607,10 +1633,19 @@
 
          CL_LOG(CL_LOG_INFO,"starting handle write thread ...");
          snprintf(help_buffer,80,"%s_write",new_handle->local->comp_name);
+
+         {
+         sigset_t old_sigmask;
+         sge_thread_block_all_signals(&old_sigmask);
+
          return_value = cl_thread_list_create_thread(cl_com_thread_list,
                                                      &(new_handle->write_thread),
                                                      cl_com_log_list,
                                                      help_buffer, 2, cl_com_handle_write_thread, NULL, NULL);
+
+         pthread_sigmask(SIG_SETMASK, &old_sigmask, NULL);
+         }
+
          if (return_value != CL_RETVAL_OK) {
             CL_LOG(CL_LOG_ERROR,"could not start handle write thread");
             thread_start_error = 1;
@@ -6703,7 +6738,6 @@
    /* get pointer to cl_thread_settings_t struct */
    cl_thread_settings_t *thread_config = (cl_thread_settings_t*)t_conf; 
 
-
    /* set thread config data */
    if (cl_thread_set_thread_config(thread_config) != CL_RETVAL_OK) {
       CL_LOG(CL_LOG_ERROR,"thread setup error"); 
@@ -6861,7 +6895,6 @@
    /* get pointer to cl_thread_settings_t struct */
    cl_thread_settings_t *thread_config = (cl_thread_settings_t*)t_conf; 
 
-
    /* set thread config data */
    if (cl_thread_set_thread_config(thread_config) != CL_RETVAL_OK) {
       CL_LOG(CL_LOG_ERROR,"thread setup error"); 
@@ -7239,7 +7272,6 @@
    /* get pointer to cl_thread_settings_t struct */
    cl_thread_settings_t *thread_config = (cl_thread_settings_t*)t_conf; 
 
-
    /* set thread config data */
    if (cl_thread_set_thread_config(thread_config) != CL_RETVAL_OK) {
       CL_LOG(CL_LOG_ERROR,"thread setup error"); 
@@ -7587,49 +7619,51 @@
       do some connection cleanup
       - remove received messages not fetched by application
     */
-   pthread_mutex_lock(handle->messages_ready_mutex); 
-   if (handle->messages_ready_for_read != 0) {
-      cl_app_message_queue_elem_t* app_mq_elem = NULL;
-      struct timeval now;
-      long timeout_time = 0;
-      cl_com_connection_t* connection = NULL;
+   if (handle != NULL) {
+      pthread_mutex_lock(handle->messages_ready_mutex); 
+      if (handle->messages_ready_for_read != 0) {
+         cl_app_message_queue_elem_t* app_mq_elem = NULL;
+         struct timeval now;
+         long timeout_time = 0;
+         cl_com_connection_t* connection = NULL;
 
-      /* compute timeout */
-      gettimeofday(&now, NULL);
+         /* compute timeout */
+         gettimeofday(&now, NULL);
 
-      cl_raw_list_lock(handle->received_message_queue);
-      app_mq_elem = cl_app_message_queue_get_first_elem(handle->received_message_queue);
-      while(app_mq_elem) {
-         cl_message_list_elem_t* message_elem = NULL;
-         cl_message_list_elem_t* next_message_elem = NULL;
-
-         connection = app_mq_elem->rcv_connection;
-         app_mq_elem = cl_app_message_queue_get_next_elem(app_mq_elem);
-
-         cl_raw_list_lock(connection->received_message_list);
-         next_message_elem = cl_message_list_get_first_elem(connection->received_message_list);
-         while(next_message_elem) {
-            cl_com_message_t* message = NULL;
-            message_elem = next_message_elem;
-            next_message_elem = cl_message_list_get_next_elem(message_elem);
-            message = message_elem->message;
-            if (message != NULL && message->message_state == CL_MS_READY) {
-               timeout_time = message->message_receive_time.tv_sec + handle->message_timeout;
-               if (timeout_time <= now.tv_sec) {
-                  CL_LOG(CL_LOG_WARNING,"removing message because of message_timeout");
-
-                  cl_message_list_remove_receive(connection, message, 0);
-                  handle->messages_ready_for_read = handle->messages_ready_for_read - 1;
-                  cl_app_message_queue_remove(handle->received_message_queue, connection, 0, CL_FALSE);
-                  cl_com_free_message(&message);
+         cl_raw_list_lock(handle->received_message_queue);
+         app_mq_elem = cl_app_message_queue_get_first_elem(handle->received_message_queue);
+         while(app_mq_elem) {
+            cl_message_list_elem_t* message_elem = NULL;
+            cl_message_list_elem_t* next_message_elem = NULL;
+
+            connection = app_mq_elem->rcv_connection;
+            app_mq_elem = cl_app_message_queue_get_next_elem(app_mq_elem);
+
+            cl_raw_list_lock(connection->received_message_list);
+            next_message_elem = cl_message_list_get_first_elem(connection->received_message_list);
+            while(next_message_elem) {
+               cl_com_message_t* message = NULL;
+               message_elem = next_message_elem;
+               next_message_elem = cl_message_list_get_next_elem(message_elem);
+               message = message_elem->message;
+               if (message != NULL && message->message_state == CL_MS_READY) {
+                  timeout_time = message->message_receive_time.tv_sec + handle->message_timeout;
+                  if (timeout_time <= now.tv_sec) {
+                     CL_LOG(CL_LOG_WARNING,"removing message because of message_timeout");
+
+                     cl_message_list_remove_receive(connection, message, 0);
+                     handle->messages_ready_for_read = handle->messages_ready_for_read - 1;
+                     cl_app_message_queue_remove(handle->received_message_queue, connection, 0, CL_FALSE);
+                     cl_com_free_message(&message);
+                  }
                }
             }
+            cl_raw_list_unlock(connection->received_message_list);
          }
-         cl_raw_list_unlock(connection->received_message_list);
+         cl_raw_list_unlock(handle->received_message_queue);
       }
-      cl_raw_list_unlock(handle->received_message_queue);
+      pthread_mutex_unlock(handle->messages_ready_mutex);
    }
-   pthread_mutex_unlock(handle->messages_ready_mutex);
 }
 
 /****** cl_commlib/cl_com_messages_in_send_queue() ****************************
diff --exclude-from=/srv/pbuilder/result/sid/sge_ignore -Naur gridengine-6.2~beta2/source/libs/comm/cl_commlib.h gridengine-6.2/source/libs/comm/cl_commlib.h
--- gridengine-6.2~beta2/source/libs/comm/cl_commlib.h	2008-06-15 15:29:54.000000000 +0100
+++ gridengine-6.2/source/libs/comm/cl_commlib.h	2008-08-08 18:14:27.000000000 +0100
@@ -46,10 +46,10 @@
 cl_raw_list_t* cl_com_get_host_list(void);
 cl_raw_list_t* cl_com_get_log_list(void);
 cl_raw_list_t* cl_com_get_endpoint_list(void);
-int cl_com_set_parameter_list_value(char* parameter, char* value);
-int cl_com_get_parameter_list_value(char* parameter, char** value);
+int cl_com_set_parameter_list_value(const char* parameter, char* value);
+int cl_com_get_parameter_list_value(const char* parameter, char** value);
 int cl_com_get_parameter_list_string(char** param_string);
-int cl_com_remove_parameter_list_value(char* parameter);
+int cl_com_remove_parameter_list_value(const char* parameter);
 int cl_com_update_parameter_list(char* parameter);
 
 /* application log functions */
diff --exclude-from=/srv/pbuilder/result/sid/sge_ignore -Naur gridengine-6.2~beta2/source/libs/comm/cl_communication.c gridengine-6.2/source/libs/comm/cl_communication.c
--- gridengine-6.2~beta2/source/libs/comm/cl_communication.c	2008-06-15 15:29:54.000000000 +0100
+++ gridengine-6.2/source/libs/comm/cl_communication.c	2008-08-08 18:14:26.000000000 +0100
@@ -4628,13 +4628,11 @@
 
          {
             char* gdi_timeout = NULL;
-            int timeout = 0;
-            int retval = 0;
-            retval = cl_com_get_parameter_list_value("gdi_timeout", &gdi_timeout);
-            if (retval != CL_RETVAL_OK || gdi_timeout == NULL) {
-               cl_com_set_synchron_receive_timeout(connection->handler, 60);
+            cl_com_get_parameter_list_value("gdi_timeout", &gdi_timeout);
+            if (gdi_timeout == NULL) {
+               cl_com_set_synchron_receive_timeout(connection->handler, CL_DEFINE_SYNCHRON_RECEIVE_TIMEOUT);
             } else {
-               timeout = atoi(gdi_timeout);
+               int timeout = atoi(gdi_timeout);
                cl_com_set_synchron_receive_timeout(connection->handler, timeout);
                free(gdi_timeout);
             }
diff --exclude-from=/srv/pbuilder/result/sid/sge_ignore -Naur gridengine-6.2~beta2/source/libs/comm/lists/cl_parameter_list.c gridengine-6.2/source/libs/comm/lists/cl_parameter_list.c
--- gridengine-6.2~beta2/source/libs/comm/lists/cl_parameter_list.c	2008-06-15 15:29:54.000000000 +0100
+++ gridengine-6.2/source/libs/comm/lists/cl_parameter_list.c	2008-08-08 18:14:27.000000000 +0100
@@ -82,7 +82,7 @@
 #undef __CL_FUNCTION__
 #endif
 #define __CL_FUNCTION__ "cl_parameter_list_append_parameter()"
-int cl_parameter_list_append_parameter(cl_raw_list_t* list_p, char* parameter, char* value, int lock_list) 
+int cl_parameter_list_append_parameter(cl_raw_list_t* list_p, const char* parameter, char* value, int lock_list) 
 {
 
    int ret_val;
@@ -157,7 +157,7 @@
 #undef __CL_FUNCTION__
 #endif
 #define __CL_FUNCTION__ "cl_parameter_list_remove_parameter()"
-int cl_parameter_list_remove_parameter(cl_raw_list_t* list_p, char* parameter, int lock_list) 
+int cl_parameter_list_remove_parameter(cl_raw_list_t* list_p, const char* parameter, int lock_list) 
 {
    int ret_val = CL_RETVAL_OK;
    int function_return = CL_RETVAL_UNKNOWN_PARAMETER;
diff --exclude-from=/srv/pbuilder/result/sid/sge_ignore -Naur gridengine-6.2~beta2/source/libs/comm/lists/cl_parameter_list.h gridengine-6.2/source/libs/comm/lists/cl_parameter_list.h
--- gridengine-6.2~beta2/source/libs/comm/lists/cl_parameter_list.h	2008-06-15 15:29:54.000000000 +0100
+++ gridengine-6.2/source/libs/comm/lists/cl_parameter_list.h	2008-08-08 18:14:27.000000000 +0100
@@ -47,8 +47,8 @@
 int cl_parameter_list_cleanup(cl_raw_list_t** list_p);
 
 /* thread list functions that will lock the list */
-int cl_parameter_list_append_parameter(cl_raw_list_t* list_p, char* parameter, char* value, int lock_list);
-int cl_parameter_list_remove_parameter(cl_raw_list_t* list_p, char* parameter, int lock_list);
+int cl_parameter_list_append_parameter(cl_raw_list_t* list_p, const char* parameter, char* value, int lock_list);
+int cl_parameter_list_remove_parameter(cl_raw_list_t* list_p, const char* parameter, int lock_list);
 int cl_parameter_list_get_param_string(cl_raw_list_t* list_p, char** param_string, int lock_list);
 
 /* thread functions that will not lock the list */
diff --exclude-from=/srv/pbuilder/result/sid/sge_ignore -Naur gridengine-6.2~beta2/source/libs/cull/cull_file.c gridengine-6.2/source/libs/cull/cull_file.c
--- gridengine-6.2~beta2/source/libs/cull/cull_file.c	2008-06-15 15:29:56.000000000 +0100
+++ gridengine-6.2/source/libs/cull/cull_file.c	2008-08-08 18:14:29.000000000 +0100
@@ -53,6 +53,7 @@
 #include "sge_log.h"
 #include "sge_io.h"
 #include "sge_unistd.h"
+#include "uti/sge_profiling.h"
 
 #include "msg_cull.h"
 
@@ -137,13 +138,15 @@
       sprintf(filename, "%s", name);
    }
 
+   PROF_START_MEASUREMENT(SGE_PROF_SPOOLINGIO);
+
    /* open file */
    if ((fd = SGE_OPEN3(filename, O_WRONLY | O_CREAT | O_TRUNC, 0666)) < 0) {
       CRITICAL((SGE_EVENT, MSG_CULL_CANTOPENXFORWRITINGOFYZ_SSS ,
                 filename, obj_name, strerror(errno)));
       clear_packbuffer(&pb);
-      DEXIT;
-      return 1;
+      PROF_STOP_MEASUREMENT(SGE_PROF_SPOOLINGIO);
+      DRETURN(1);
    }
 
    /* write packing buffer */
@@ -152,16 +155,16 @@
                filename));
       clear_packbuffer(&pb);
       close(fd);
-      DEXIT;
-      return 1;
+      PROF_STOP_MEASUREMENT(SGE_PROF_SPOOLINGIO);
+      DRETURN(1);
    }
 
    /* close file and exit */
    close(fd);
+   PROF_STOP_MEASUREMENT(SGE_PROF_SPOOLINGIO);
    clear_packbuffer(&pb);
 
-   DEXIT;
-   return 0;
+   DRETURN(0);
 }
 
 /****** cull/file/lReadElemFromDisk() ****************************************
diff --exclude-from=/srv/pbuilder/result/sid/sge_ignore -Naur gridengine-6.2~beta2/source/libs/cull/pack.c gridengine-6.2/source/libs/cull/pack.c
--- gridengine-6.2~beta2/source/libs/cull/pack.c	2008-06-15 15:29:56.000000000 +0100
+++ gridengine-6.2/source/libs/cull/pack.c	2008-08-08 18:14:29.000000000 +0100
@@ -174,10 +174,9 @@
       memset(pb, 0, sizeof(sge_pack_buffer));
  
       pb->head_ptr = malloc(initial_size);
-      if (!pb->head_ptr) {
+      if (pb->head_ptr == NULL) {
          ERROR((SGE_EVENT, MSG_CULL_NOTENOUGHMEMORY_D, initial_size));
-         DEXIT;
-         return PACK_ENOMEM;
+         DRETURN(PACK_ENOMEM);
       }
       pb->cur_ptr = pb->head_ptr;
       pb->mem_size = initial_size;
diff --exclude-from=/srv/pbuilder/result/sid/sge_ignore -Naur gridengine-6.2~beta2/source/libs/gdi/msg_gdilib.h gridengine-6.2/source/libs/gdi/msg_gdilib.h
--- gridengine-6.2~beta2/source/libs/gdi/msg_gdilib.h	2008-06-15 15:29:57.000000000 +0100
+++ gridengine-6.2/source/libs/gdi/msg_gdilib.h	2008-08-08 18:14:30.000000000 +0100
@@ -110,7 +110,7 @@
 #define MSG_GDI_UNABLE_TO_CONNECT_SUS                    _MESSAGE(43119, _("unable to contact "SFN" using port "sge_U32CFormat" on host "SFQ))
 #define MSG_GDI_GETGRGIDXFAILEDERRORX_U                  _MESSAGE(43120, _("unable to resolve group name for group ID, "sge_U32CFormat))
 #define MSG_GDI_SENDINGGDIREQUESTFAILED                  _MESSAGE(43121, _("failed sending gdi request"))
-#define MSG_GDI_RECEIVEGDIREQUESTFAILED                  _MESSAGE(43122, _("failed receiving gdi request"))
+#define MSG_GDI_RECEIVEGDIREQUESTFAILED_US               _MESSAGE(43122, _("failed receiving gdi request response for mid="sge_U32CFormat" ("SFN")."))
 #define MSG_GDI_REQUESTFORMATERROR                       _MESSAGE(43124, _("format error while packing gdi request"))
 #define MSG_GDI_UNEXPECTEDERRORWHILEPACKINGGDIREQUEST    _MESSAGE(43125, _("unexpected error while packing gdi request"))
 #define MSG_GDI_ERRORUNPACKINGGDIREQUEST_S               _MESSAGE(43126, _("error unpacking gdi request: "SFN))
diff --exclude-from=/srv/pbuilder/result/sid/sge_ignore -Naur gridengine-6.2~beta2/source/libs/gdi/sge_gdi2.c gridengine-6.2/source/libs/gdi/sge_gdi2.c
--- gridengine-6.2~beta2/source/libs/gdi/sge_gdi2.c	2008-06-15 15:29:57.000000000 +0100
+++ gridengine-6.2/source/libs/gdi/sge_gdi2.c	2008-08-08 18:14:30.000000000 +0100
@@ -302,10 +302,10 @@
    id = sge_gdi2_multi(ctx, &alp, SGE_GDI_SEND, target, cmd, lpp, 
                        cp, enp, &state, true);
    if (id != -1) {
-      local_ret = sge_gdi2_wait(ctx, &alp, &mal, &state); 
+      local_ret = sge_gdi2_wait(ctx, &alp, &mal, &state);
       if (local_ret == true) {
          sge_gdi_extract_answer(&alp, cmd, target, id, mal, lpp);
-      } 
+      }
       lFreeList(&mal);
    }
    PROF_STOP_MEASUREMENT(SGE_PROF_GDI);
@@ -354,11 +354,15 @@
             local_ret = ctx->sge_gdi_packet_execute(ctx, alpp, packet);
             if (local_ret == false) {
                /* answer has been written in ctx->sge_gdi_packet_execute() */
+               sge_gdi_packet_free(&packet);
+               state->packet = NULL;
                ret = -1;
             }
          } 
       } else {
          /* answer list has been filled by sge_gdi_packet_append_task() */
+         sge_gdi_packet_free(&packet);
+         state->packet = NULL;
          ret = -1;
       }
    } else {
diff --exclude-from=/srv/pbuilder/result/sid/sge_ignore -Naur gridengine-6.2~beta2/source/libs/gdi/sge_gdi_packet_internal.c gridengine-6.2/source/libs/gdi/sge_gdi_packet_internal.c
--- gridengine-6.2~beta2/source/libs/gdi/sge_gdi_packet_internal.c	2008-06-15 15:29:57.000000000 +0100
+++ gridengine-6.2/source/libs/gdi/sge_gdi_packet_internal.c	2008-08-08 18:14:30.000000000 +0100
@@ -305,6 +305,78 @@
    DRETURN_VOID;   
 }
 
+
+/****** gdi/request/get_gdi_retries_value() ***************************************
+*  NAME
+*     get_gdi_retries_value() -- get commlib parameter list value "gdi_retries"
+*
+*  SYNOPSIS
+*     static int get_gdi_retries_value(void) 
+*
+*  FUNCTION
+*     Returns the nr of retries on synchron receive retries when getting a
+*     GDI response message.
+*
+*  INPUTS
+*     void - none
+*
+*  RESULT
+*     static int - configured "gdi_retries" value (set by qmaster_params)
+*
+*  SEE ALSO
+*     gdi/request/get_cl_ping_value()
+*     gdi/request/get_gdi_retries_value()
+*******************************************************************************/
+static int get_gdi_retries_value(void) {
+   char* gdi_retries = NULL;
+   int retries = 0;
+   cl_com_get_parameter_list_value("gdi_retries", &gdi_retries);
+   if (gdi_retries != NULL) {
+      retries = atoi(gdi_retries);
+      FREE(gdi_retries);
+   }
+   return retries;
+}
+
+/****** gdi/request/get_cl_ping_value() *******************************************
+*  NAME
+*     get_cl_ping_value() -- get commlib parameter list value "cl_ping"
+*
+*  SYNOPSIS
+*     static bool get_cl_ping_value(void) 
+*
+*  FUNCTION
+*     Returns the value of the "cl_ping" commlib parameter. The value is true
+*     or false and specifies if gdi should send a SIM message to qmaster which
+*     should be used for desiction making if qmaster is still working or
+*     unreachable.
+*
+*  INPUTS
+*     void - none
+*
+*  RESULT
+*     static bool - true or false (enabled or disabled)
+*
+*  SEE ALSO
+*     gdi/request/get_cl_ping_value()
+*     gdi/request/get_gdi_retries_value()
+*******************************************************************************/
+static bool get_cl_ping_value(void) {
+   char* cl_ping = NULL;
+   bool do_ping = false;
+
+   cl_com_get_parameter_list_value("cl_ping", &cl_ping);
+   if (cl_ping != NULL) {
+      if (strcasecmp(cl_ping, "true") == 0) {
+         do_ping = true;
+      }
+      FREE(cl_ping);
+   }
+   return do_ping;
+}
+
+
+
 /****** gdi/request_internal/sge_gdi_packet_execute_external() ****************
 *  NAME
 *     sge_gdi_packet_execute_external() -- execute a GDI packet 
@@ -411,10 +483,8 @@
       const char *host = ctx->get_master(ctx, false);
       int id = 1;
       int response_id = 0;
-      lList *tmp_answer_list = NULL;
-
       commlib_error = sge_gdi2_send_any_request(ctx, 0, &message_id, host, commproc, id, &pb,
-                                                TAG_GDI_REQUEST, response_id, &tmp_answer_list);
+                                                TAG_GDI_REQUEST, response_id, NULL);
       if (commlib_error != CL_RETVAL_OK) {
          ret = false;
          commlib_error = ctx->is_alive(ctx);
@@ -435,7 +505,6 @@
                                       mastername?mastername:"<NULL>", 
                                       cl_get_error_text(commlib_error))); 
             }
-            lFreeList(&tmp_answer_list);
          } else {
             SGE_ADD_MSG_ID(sprintf(SGE_EVENT, MSG_GDI_SENDINGGDIREQUESTFAILED));
          }
@@ -444,6 +513,9 @@
       }
    }
 
+   /* after this point we do no longer need pb - free its resources */
+   clear_packbuffer(&pb);
+
    /* 
     * wait for response from master; also here keep care that commlib
     * related error messages are hidden if master is not up and running anymore
@@ -455,111 +527,101 @@
       char rcv_commproc[CL_MAXHOSTLEN+1];
       int tag = TAG_GDI_REQUEST;
       u_short id = 1;
-      char* cl_ping = NULL;
-      char* gdi_retries = NULL;
-      int retries = 1;
-      bool do_cl_ping = false;
-      int doit = 0;
       int gdi_error = CL_RETVAL_OK;
+      int runs = 0;
+      int runs_at_start = 0;
+      bool do_ping = false;
+      bool do_permanent = false;
 
       strcpy(rcv_host, host);
       strcpy(rcv_commproc, commproc);
 
-      cl_com_get_parameter_list_value("cl_ping", &cl_ping);
-      if (cl_ping != NULL) {
-         if (strcasecmp(cl_ping, "true") == 0) {
-            do_cl_ping = true;
-         }
-         FREE(cl_ping);
-      }
-      cl_com_get_parameter_list_value("gdi_retries", &gdi_retries);
-      if (gdi_retries != NULL) {
-         retries = atoi(gdi_retries);
-         FREE(gdi_retries);
-         retries++;
-      }
+      do_ping = get_cl_ping_value();
+      runs = get_gdi_retries_value();
+      runs_at_start = runs;
 
-      if (retries <= 0) {
-         doit = retries - 2; 
+      if (runs == -1) {
+         do_permanent = true;
       }
 
-      /*running this loop as long as configured in gdi_retries, doing a break after getting a gdi_request*/
-      while (doit <= retries - 1) {
-         DPRINTF(("calling the sge_gdi2_get_any_request: %d times\n",retries));
-         DPRINTF(("retry: %d\n",doit));
 
+      /*running this loop as long as configured in gdi_retries, doing a break after getting a gdi_request*/
+      do {
          gdi_error = sge_gdi2_get_any_request(ctx, rcv_host, rcv_commproc, &id, &rpb, &tag, 
                                                   true, message_id, NULL);
-         if (gdi_error != CL_RETVAL_OK) {
+
+         if (gdi_error == CL_RETVAL_OK) {
+            /*no error happened, leaving while*/
+            ret = true;
+            break;
+         } else {
             ret = false;
-            commlib_error = ctx->is_alive(ctx);
-            if (commlib_error != CL_RETVAL_OK) {
-               u_long32 sge_qmaster_port = ctx->get_sge_qmaster_port(ctx);
-               const char *mastername = ctx->get_master(ctx, false);
-
-               if (commlib_error == CL_RETVAL_CONNECT_ERROR ||
-                   commlib_error == CL_RETVAL_CONNECTION_NOT_FOUND ) {
-                  /* For the default case, just print a simple message */
-                  SGE_ADD_MSG_ID(sprintf(SGE_EVENT, MSG_GDI_UNABLE_TO_CONNECT_SUS,
-                                         prognames[QMASTER], sge_u32c(sge_qmaster_port),
-                                         mastername?mastername:"<NULL>"));            
-                  answer_list_add(answer_list, SGE_EVENT, STATUS_NOQMASTER, ANSWER_QUALITY_ERROR);
-               } else { 
-                  /* For unusual errors, give more detail */
-                  SGE_ADD_MSG_ID(sprintf(SGE_EVENT, MSG_GDI_CANT_SEND_MSG_TO_PORT_ON_HOST_SUSS,
-                                         prognames[QMASTER], sge_u32c(sge_qmaster_port),
-                                         mastername?mastername:"<NULL>", 
-                                         cl_get_error_text(commlib_error))); 
-                  answer_list_add(answer_list, SGE_EVENT, STATUS_NOQMASTER, ANSWER_QUALITY_ERROR);
+            /*this error appears, if qmaster or any qmaster thread is not responding, or overloaded*/
+            if (gdi_error == CL_RETVAL_SYNC_RECEIVE_TIMEOUT) {
+               cl_com_SIRM_t* cl_endpoint_status = NULL;
+               cl_com_handle_t* handle = NULL;
+               DPRINTF(("TEST_2372_OUTPUT: CL_RETVAL_SYNC_RECEIVE_TIMEOUT: RUNS="sge_U32CFormat"\n", sge_u32c(runs)));
+
+               handle = ctx->get_com_handle(ctx);
+               if (handle != NULL) {
+                  DPRINTF(("TEST_2372_OUTPUT: GDI_TIMEOUT="sge_U32CFormat"\n", sge_u32c(handle->synchron_receive_timeout)));
                }
-            } else {
-               /*this error appears, if qmaster or any qmaster thread is not responding, or overloaded*/
-               if (gdi_error == CL_RETVAL_SYNC_RECEIVE_TIMEOUT) {
-                  cl_com_SIRM_t* cl_endpoint_status = NULL;
-                  cl_com_handle_t* handle = NULL;
-
-                  DPRINTF(("failed receiving gdi response. Commlib returned: "SFQ"\n", cl_get_error_text(gdi_error)));
-                  handle = ctx->get_com_handle(ctx);
-
-                  DPRINTF(("gdi timeout is set to: %d\n", handle->synchron_receive_timeout));
-                  if (do_cl_ping) {
-                     DPRINTF(("sending qping to commlib!\n"));
-                     cl_commlib_get_endpoint_status(handle, rcv_host, rcv_commproc, id, &cl_endpoint_status);
-
+               if (do_ping == true) {
+                  DPRINTF(("TEST_2372_OUTPUT: CL_PING=TRUE\n"));
+                  cl_commlib_get_endpoint_status(handle, rcv_host, rcv_commproc, id, &cl_endpoint_status);
+                  if (cl_endpoint_status != NULL) {
                      if (cl_endpoint_status->application_status != 0) {
-                        DPRINTF(("qmaster status is not ok!\n"));
-                        DPRINTF(("some qmaster threads may have crashed or overloaded\n"));
+                        DPRINTF(("TEST_2372_OUTPUT: QPING: error\n"));
                      } else {
-                        DPRINTF(("qmaster application status is ok. qmaster is working.\n"));
-                        DPRINTF(("commlib seems to be ok, but commlib returned: "SFQ"\n", cl_get_error_text(gdi_error)));
+                        DPRINTF(("TEST_2372_OUTPUT: QPING: ok\n"));
                      }
-                     DPRINTF(("Message Number: %d\n", cl_endpoint_status->application_messages_brm));
-                     DPRINTF(("Application Status: %d\n", cl_endpoint_status->application_status));
-                     DPRINTF(("The qmaster seems to be overloaded!!!!!\n"));
-                     DPRINTF(("Setting a higher timeout or raise the number of retires may solve this problem\n"));
                      cl_com_free_sirm_message(&cl_endpoint_status);
-                  }
-                  /*only, if the last retry is also failed, the error message will be added to the answer list*/
-                  /*else, we get this error message as often as configured in gdi_retries*/
-                  if (doit == retries - 1) {
-                     SGE_ADD_MSG_ID(sprintf(SGE_EVENT, MSG_GDI_SYNCRECEIVETIMEOUT));
-                     answer_list_add(answer_list, SGE_EVENT, STATUS_NOQMASTER, ANSWER_QUALITY_ERROR);
+                  } else {
+                     DPRINTF(("TEST_2372_OUTPUT: QPING: failed\n"));
+                     break;
                   }
                } else {
-                  /*this error message will be printed, if the happened error is not a commlib or a gdi sync error*/ 
-                  SGE_ADD_MSG_ID(sprintf(SGE_EVENT, MSG_GDI_RECEIVEGDIREQUESTFAILED));
-                  answer_list_add(answer_list, SGE_EVENT, STATUS_NOQMASTER, ANSWER_QUALITY_ERROR);
+                  DPRINTF(("TEST_2372_OUTPUT: CL_PING=FALSE\n"));
                }
+            } else {
+               break;
             }
-            if (retries > 0) {
-               doit++;
+         }
+         if (get_gdi_retries_value() != runs_at_start) {
+            DPRINTF(("Value changed during request - break\n"));
+            break;
+         }
+         /* 
+          * only decrement runs if do_permanent is true. do_permanent is set to true
+          * if qmaster_params value for gdi_retries is set to -1 (see man page) 
+          */
+      } while (do_permanent == true || runs-- > 0);
+
+      if (ret == false) {
+         commlib_error = ctx->is_alive(ctx);
+         if (commlib_error != CL_RETVAL_OK) {
+            u_long32 sge_qmaster_port = ctx->get_sge_qmaster_port(ctx);
+            const char *mastername = ctx->get_master(ctx, false);
+
+            if (commlib_error == CL_RETVAL_CONNECT_ERROR ||
+                commlib_error == CL_RETVAL_CONNECTION_NOT_FOUND ) {
+               /* For the default case, just print a simple message */
+               SGE_ADD_MSG_ID(sprintf(SGE_EVENT, MSG_GDI_UNABLE_TO_CONNECT_SUS,
+                                      prognames[QMASTER], sge_u32c(sge_qmaster_port),
+                                      mastername?mastername:"<NULL>"));            
+            } else { 
+               /* For unusual errors, give more detail */
+               SGE_ADD_MSG_ID(sprintf(SGE_EVENT, MSG_GDI_CANT_SEND_MSG_TO_PORT_ON_HOST_SUSS,
+                                      prognames[QMASTER], sge_u32c(sge_qmaster_port),
+                                      mastername?mastername:"<NULL>", 
+                                      cl_get_error_text(commlib_error))); 
             }
-            ret = false;
          } else {
-            /*no error happened, leaving while*/
-            ret = true;
-            break;
+            SGE_ADD_MSG_ID(sprintf(SGE_EVENT, MSG_GDI_RECEIVEGDIREQUESTFAILED_US,
+                    sge_u32c(message_id),
+                    cl_get_error_text(gdi_error)));
          }
+         answer_list_add(answer_list, SGE_EVENT, STATUS_NOQMASTER, ANSWER_QUALITY_ERROR);
       }
    }
 
diff --exclude-from=/srv/pbuilder/result/sid/sge_ignore -Naur gridengine-6.2~beta2/source/libs/gdi/sge_security.c gridengine-6.2/source/libs/gdi/sge_security.c
--- gridengine-6.2~beta2/source/libs/gdi/sge_security.c	2008-06-15 15:29:57.000000000 +0100
+++ gridengine-6.2/source/libs/gdi/sge_security.c	2008-08-08 18:14:30.000000000 +0100
@@ -298,6 +298,8 @@
                  SGE_COMMD_SERVICE, sge_get_default_cell());
       }
       user_local_dir = userdir;
+
+      FREE(buffer);
    }
 
 
diff --exclude-from=/srv/pbuilder/result/sid/sge_ignore -Naur gridengine-6.2~beta2/source/libs/gdi/version.c gridengine-6.2/source/libs/gdi/version.c
--- gridengine-6.2~beta2/source/libs/gdi/version.c	2008-06-15 15:29:57.000000000 +0100
+++ gridengine-6.2/source/libs/gdi/version.c	2008-08-08 18:14:30.000000000 +0100
@@ -34,7 +34,7 @@
 
 #include "gdi/version.h"
 
-const char GDI_VERSION[] = "maintrunk";
+const char GDI_VERSION[] = "6.2";
 
 const gdi_ulong32 GRM_GDI_VERSION = 0x100020F1;
 
diff --exclude-from=/srv/pbuilder/result/sid/sge_ignore -Naur gridengine-6.2~beta2/source/libs/mir/sge_mirror.c gridengine-6.2/source/libs/mir/sge_mirror.c
--- gridengine-6.2~beta2/source/libs/mir/sge_mirror.c	2008-06-15 15:29:57.000000000 +0100
+++ gridengine-6.2/source/libs/mir/sge_mirror.c	2008-08-08 18:14:29.000000000 +0100
@@ -1823,7 +1823,7 @@
 
       case SGE_EMA_MOD:
          /* check for existence */
-         if(ep == NULL) {
+         if (ep == NULL) {
             ERROR((SGE_EVENT, "element "SFQ" does not exist\n", (key != NULL) ?key:"NULL"));
             DRETURN(SGE_EM_KEY_NOT_FOUND);
          }
diff --exclude-from=/srv/pbuilder/result/sid/sge_ignore -Naur gridengine-6.2~beta2/source/libs/mir/sge_sched_conf_mirror.c gridengine-6.2/source/libs/mir/sge_sched_conf_mirror.c
--- gridengine-6.2~beta2/source/libs/mir/sge_sched_conf_mirror.c	2008-06-15 15:29:57.000000000 +0100
+++ gridengine-6.2/source/libs/mir/sge_sched_conf_mirror.c	2008-08-08 18:14:29.000000000 +0100
@@ -101,7 +101,7 @@
       lAppendElem(list, ep);
    }
 
-   if (sconf_set_config(&list, &answer_list)){
+   if (!sconf_set_config(&list, &answer_list)) {
       lFreeList(&list);
       answer_list_output(&answer_list);
    }
diff --exclude-from=/srv/pbuilder/result/sid/sge_ignore -Naur gridengine-6.2~beta2/source/libs/sched/msg_schedd.h gridengine-6.2/source/libs/sched/msg_schedd.h
--- gridengine-6.2~beta2/source/libs/sched/msg_schedd.h	2008-06-15 15:29:56.000000000 +0100
+++ gridengine-6.2/source/libs/sched/msg_schedd.h	2008-08-08 18:14:28.000000000 +0100
@@ -174,7 +174,7 @@
 #define MSG_SCHEDD_INFO_CANNOTRUNRQS                  _MESSAGE(47141, _("Jobs cannot run because they exceeds limit in resource quota sets")) 
 #define MSG_SCHEDD_INFO_JOBDYNAMICALLIMIT_SS          _MESSAGE(47142, _("Job dropped because of invalid dynamical limit "SFN" in rule "SFN)) 
 #define MSG_SCHEDD_INFO_JOBDYNAMICALLIMIT             _MESSAGE(47143, _("Jobs dropped because of invalid dynamical limit")) 
-#define MSG_SCHEDD_INFO_CANNOTRUNRQSGLOBAL_SS         _MESSAGE(47144, _("Job cannot run because it exceeds limit "SFQ" in rule "SFQ))
+#define MSG_SCHEDD_INFO_CANNOTRUNRQSGLOBAL_SS         _MESSAGE(47144, _("cannot run because it exceeds limit "SFQ" in rule "SFQ))
 #define MSG_SCHEDD_INFO_CANNOTRUNRQSGLOBAL            _MESSAGE(47145, _("Jobs dropped because exceeds limit in rule")) 
 #define MSG_SCHEDD_INFO_QINOTARRESERVED_SI            _MESSAGE(47146, _("cannot run in queue instance "SFQ" because it was not reserved by advance reservation "sge_U32CFormat))
 #define MSG_SCHEDD_INFO_QINOTARRESERVED               _MESSAGE(47147, _("Jobs can not run because queue instance was not reserved by advance reservation"))  
diff --exclude-from=/srv/pbuilder/result/sid/sge_ignore -Naur gridengine-6.2~beta2/source/libs/sched/schedd_monitor.c gridengine-6.2/source/libs/sched/schedd_monitor.c
--- gridengine-6.2~beta2/source/libs/sched/schedd_monitor.c	2008-06-15 15:29:56.000000000 +0100
+++ gridengine-6.2/source/libs/sched/schedd_monitor.c	2008-08-08 18:14:28.000000000 +0100
@@ -83,11 +83,6 @@
    return log_string;
 }
 
-void clean_monitor_alp()
-{
-   lFreeList(monitor_alpp);
-}
-
 void set_monitor_alpp(lList **alpp) {
    monitor_alpp = alpp;
    monitor_next_run = (alpp!=NULL)?true:false;
@@ -103,10 +98,7 @@
    }
 
    if (monitor_alpp) {
-      char logloglog[2048];
-/*       DPRINTF(("schedd_log: %s\n", logstr)); */
-      sprintf(logloglog, "%s", logstr);
-      answer_list_add(monitor_alpp, logloglog, STATUS_ESEMANTIC, ANSWER_QUALITY_ERROR);
+      answer_list_add(monitor_alpp, logstr, STATUS_ESEMANTIC, ANSWER_QUALITY_ERROR);
    } 
    else {
       time_t now;
diff --exclude-from=/srv/pbuilder/result/sid/sge_ignore -Naur gridengine-6.2~beta2/source/libs/sched/schedd_monitor.h gridengine-6.2/source/libs/sched/schedd_monitor.h
--- gridengine-6.2~beta2/source/libs/sched/schedd_monitor.h	2008-06-15 15:29:56.000000000 +0100
+++ gridengine-6.2/source/libs/sched/schedd_monitor.h	2008-08-08 18:14:28.000000000 +0100
@@ -36,9 +36,6 @@
 
 #define SCHED_LOG_NAME "schedd_runlog"
 
-/* free answer list if anyone is registered */
-void clean_monitor_alp(void);
-
 /* registers answer list to be used */
 void set_monitor_alpp(lList **alpp);
 
diff --exclude-from=/srv/pbuilder/result/sid/sge_ignore -Naur gridengine-6.2~beta2/source/libs/sched/sgeee.c gridengine-6.2/source/libs/sched/sgeee.c
--- gridengine-6.2~beta2/source/libs/sched/sgeee.c	2008-06-15 15:29:56.000000000 +0100
+++ gridengine-6.2/source/libs/sched/sgeee.c	2008-08-08 18:14:28.000000000 +0100
@@ -3892,8 +3892,7 @@
                   order_list = sge_create_orders(order_list, ORT_ptickets, job, task_template, NULL, false);
                }
             }  
-         }
-         else {
+         } else {
             order_list = sge_create_orders(order_list, ORT_clear_pri_info, job, NULL, NULL, false);               
          }
       }
diff --exclude-from=/srv/pbuilder/result/sid/sge_ignore -Naur gridengine-6.2~beta2/source/libs/sched/sge_job_schedd.c gridengine-6.2/source/libs/sched/sge_job_schedd.c
--- gridengine-6.2~beta2/source/libs/sched/sge_job_schedd.c	2008-06-15 15:29:56.000000000 +0100
+++ gridengine-6.2/source/libs/sched/sge_job_schedd.c	2008-08-08 18:14:28.000000000 +0100
@@ -512,7 +512,7 @@
 *
 *  SYNOPSIS
 *     void split_jobs(lList **job_list, lList **answer_list, 
-*                     lList *queue_list, u_long32 max_aj_instances, 
+*                     u_long32 max_aj_instances, 
 *                     lList **result_list[]) 
 *
 *  FUNCTION
@@ -528,18 +528,14 @@
 *     Each of those lists containes jobs which have a certain state.
 *     (e.g. result_list[SPLIT_WAITING_DUE_TO_TIME] will contain
 *     all jobs which have to wait according to their start time. 
-*     'queue_list' is the whole list of configured queues.
 *     'max_aj_instances' are the maximum number of tasks of an 
 *     array job which may be instantiated at the same time.
-*     'queue_list' and 'max_aj_instances' are used for the
-*     split decitions. 
+*     'max_aj_instances' is used for the split decitions. 
 *     In case of any error the 'answer_list' will be used to report
 *     errors (It is not used in the moment)
 *
 *  INPUTS
 *     lList **job_list          - JB_Type input list 
-*     lList **answer_list       - AN_Type answer list 
-*     lList *queue_list         - QU_Type list 
 *     u_long32 max_aj_instances - max. num. of task instances 
 *     lList **result_list[]     - Array of result list (JB_Type)
 *
@@ -559,9 +555,8 @@
 *     sched/sge_job_schedd/trash_splitted_jobs()
 *     sched/sge_job_schedd/job_lists_split_with_reference_to_max_running()
 *******************************************************************************/
-void split_jobs(lList **job_list, lList **answer_list,
-                lList *queue_list, u_long32 max_aj_instances, 
-                lList **result_list[], bool is_free_job_list, bool do_copy)
+void split_jobs(lList **job_list, u_long32 max_aj_instances, 
+                lList **result_list[], bool do_copy)
 {
 #if 0 /* EB: DEBUG: enable debug messages for split_jobs() */
 #define JOB_SPLIT_DEBUG
@@ -897,17 +892,7 @@
       }
    }
 
-   /*
-    * Could we dispense all jobs?
-    */
-   if (!do_copy && is_free_job_list == true) {
-      if (lGetNumberOfElem(*job_list) == 0) {
-         lFreeList(job_list);
-      }
-   }
-
-   DEXIT;
-   return;
+   DRETURN_VOID;
 } 
 
 /****** sched/sge_job_schedd/trash_splitted_jobs() ****************************
diff --exclude-from=/srv/pbuilder/result/sid/sge_ignore -Naur gridengine-6.2~beta2/source/libs/sched/sge_job_schedd.h gridengine-6.2/source/libs/sched/sge_job_schedd.h
--- gridengine-6.2~beta2/source/libs/sched/sge_job_schedd.h	2008-06-15 15:29:56.000000000 +0100
+++ gridengine-6.2/source/libs/sched/sge_job_schedd.h	2008-08-08 18:14:29.000000000 +0100
@@ -178,9 +178,8 @@
 };
 
 void 
-split_jobs(lList **job_list, lList **answer_list, lList *queue_list,
-           u_long32 max_aj_instances, lList **result_lists[],
-           bool is_free_job_list, bool do_copy); 
+split_jobs(lList **job_list, u_long32 max_aj_instances,
+           lList **result_lists[], bool do_copy); 
 
 void 
 job_lists_split_with_reference_to_max_running(lList **job_lists[],
diff --exclude-from=/srv/pbuilder/result/sid/sge_ignore -Naur gridengine-6.2~beta2/source/libs/sched/sge_select_queue.c gridengine-6.2/source/libs/sched/sge_select_queue.c
--- gridengine-6.2~beta2/source/libs/sched/sge_select_queue.c	2008-06-15 15:29:56.000000000 +0100
+++ gridengine-6.2/source/libs/sched/sge_select_queue.c	2008-08-08 18:14:29.000000000 +0100
@@ -3680,9 +3680,10 @@
 {
    lListElem *job = a->job;
    bool need_master_host = (lGetList(job, JB_master_hard_queue_list) != NULL) ? true : false;
+   bool have_hard_queue_request = (lGetList(job, JB_hard_queue_list) != NULL) ? true : false;
 
    int accu_host_slots, accu_host_slots_qend;
-   bool have_master_host, have_master_host_qend, suited_as_master_host, suited_as_master_host_qend = false;
+   bool have_master_host, have_master_host_qend, suited_as_master_host;
    lListElem *hep;
    dispatch_t best_result = DISPATCH_NEVER_CAT; 
    int gslots = a->slots;
@@ -3701,9 +3702,6 @@
       schedd_mes_set_tmp_list(use_category->cache, CCT_job_messages, a->job_id);
    }
 
-   /* remove reasons from last unsuccesful iteration */ 
-   clean_monitor_alp();
-
    if (lGetUlong(a->job, JB_ar) == 0) {
       if (a->pi)
          a->pi->par_global++;
@@ -3814,7 +3812,7 @@
                      While considering allocation_rule and master queue demand we try to get as 
                      much from each queue as needed, but not more than 'maxslots'. When we are through 
                      all queue instances and got not even 'minslots' the slots must be undebited. */
-                  bool got_master_queue = false;
+                  bool got_master_queue = have_master_host;
                   lListElem *qep;
                   int rqs_hslots = 0, maxslots, slots, slots_qend;
 
@@ -3843,14 +3841,15 @@
                      if (need_master_host) {
                         /* care for slave tasks assignments of -masterq jobs */
                         if (!have_master_host && !got_master_queue && lGetUlong(qep, QU_tagged4schedule)==0 
-                             && accu_host_slots + rqs_hslots + slots == a->slots)
-                              slots--;
+                             && accu_host_slots + rqs_hslots + slots == a->slots) {
+                           slots--;
+                        }
                         /* care for master tasks assignments of -masterq jobs */
                         if (lGetUlong(qep, QU_tagged4schedule)==1) {
-                           if (!have_master_host && !got_master_queue)
-                              slots = MIN(slots, 1);
-                           else
-                              slots = 0;
+                           if (!have_master_host && !got_master_queue && have_hard_queue_request) {
+                              if (have_hard_queue_request) 
+                                 slots = MIN(slots, 1);
+                           } 
                         }
                      }
 
@@ -3916,17 +3915,16 @@
                         }
                      }
                      hslots = 0;
-                     suited_as_master_host = false;
                   } else {
                      if (got_master_queue)
-                        suited_as_master_host = true;
+                        have_master_host = true;
                      accu_host_slots += rqs_hslots;
                   }
                }
 
                if ( hslots_qend >= minslots && a->care_reservation && !a->is_reservation) {
                   lListElem *qep;
-                  bool got_master_queue = false;
+                  bool got_master_queue_qend = have_master_host_qend;
                   int rqs_hslots = 0, maxslots, slots, slots_qend;
 
                   /* still broken for cases where round robin requires multiple rounds */
@@ -3947,15 +3945,13 @@
 
                      if (need_master_host) {
                         /* care for slave tasks assignments of -masterq jobs */
-                        if (!have_master_host_qend && !got_master_queue && lGetUlong(qep, QU_tagged4schedule)==0
+                        if (!have_master_host_qend && !got_master_queue_qend && lGetUlong(qep, QU_tagged4schedule)==0
                             && accu_host_slots_qend + rqs_hslots + slots_qend == a->slots)
                            slots_qend--;
                         /* care for master tasks assignments of -masterq jobs */
                         if (need_master_host && lGetUlong(qep, QU_tagged4schedule)==1) {
-                           if (!have_master_host_qend && !got_master_queue)
-                              slots_qend = MIN(slots_qend, 1);
-                           else
-                              slots_qend = 0;
+                           if (!have_master_host_qend && !got_master_queue_qend && have_hard_queue_request) 
+                               slots_qend = MIN(slots_qend, 1);
                         }
                      }
 
@@ -3989,15 +3985,11 @@
                      }
                      hslots_qend = 0;
                   } else {
-                     if (got_master_queue)
-                        suited_as_master_host_qend = true;
+                     if (got_master_queue_qend) 
+                        have_master_host_qend = true;
                      accu_host_slots_qend += rqs_hslots;
                   }
                }
-
-               /* tag full amount or zero */
-               have_master_host |= suited_as_master_host;
-               have_master_host_qend |= suited_as_master_host_qend;
             }
 
             /* mark host as not suitable */
@@ -4046,6 +4038,20 @@
          best_result = DISPATCH_NEVER_CAT;
       }
 
+      /* could be interesting for future diagnosis that unveils what resources the job could get 
+         as of now we got only negative diagnosis information i.e. reasons why/where no resources are/available */
+#if 0
+      if (best_result != DISPATCH_OK) {
+         dstring sched_info = DSTRING_INIT;
+         for_each (gdil_ep, a->gdil) {
+            sge_dstring_sprintf(&sched_info, "   HOST: %s QUEUE: %s SLOTS %d", 
+               lGetHost(gdil_ep, JG_qhostname), lGetString(gdil_ep, JG_qname), (int)lGetUlong(gdil_ep, JG_slots));
+            schedd_log(sge_dstring_get_string(&sched_info));
+         }
+         sge_dstring_free(&sched_info);
+      }
+#endif
+
       *available_slots = accu_host_slots;
 
       if (rmon_condition(xaybzc, INFOPRINT)) {
@@ -5840,7 +5846,6 @@
    int avail_qend = 0;
    int max_slots = INT_MAX, max_slots_qend = INT_MAX;
    const char *name;
-   static lListElem *implicit_slots_request = NULL;
    lListElem *tep, *cep, *actual, *req;
    dispatch_t result;
 
@@ -5850,19 +5855,21 @@
 
    clear_resource_tags(requests, QUEUE_TAG); 
 
-   if (!implicit_slots_request) {
-      implicit_slots_request = lCreateElem(CE_Type);
-      lSetString(implicit_slots_request, CE_name, SGE_ATTR_SLOTS);
-      lSetString(implicit_slots_request, CE_stringval, "1");
-      lSetDouble(implicit_slots_request, CE_doubleval, 1);
-   }
-
    /* --- implicit slot request */
    name = SGE_ATTR_SLOTS;
    if (!(tep = lGetElemStr(total_list, CE_name, name)) && force_slots) {
       DRETURN(DISPATCH_OK); /* ??? Is this correct? Should be DISPATCH_NEVER_CAT */
    }
+
    if (tep) {
+      static lListElem *implicit_slots_request = NULL;
+      if (!implicit_slots_request) {
+         implicit_slots_request = lCreateElem(CE_Type);
+         lSetString(implicit_slots_request, CE_name, SGE_ATTR_SLOTS);
+         lSetString(implicit_slots_request, CE_stringval, "1");
+         lSetDouble(implicit_slots_request, CE_doubleval, 1);
+      }
+
       if (ri_slots_by_time(a, &avail, &avail_qend, 
             rue_list, implicit_slots_request, load_attr, total_list, queue, layer, lc_factor, 
             &reason, allow_non_requestable, false, object_name)) {
@@ -5902,12 +5909,14 @@
                if (ri_slots_by_time(a, &avail, &avail_qend, 
                         rue_list, cep, load_attr, total_list, queue, layer, lc_factor,   
                         &reason, allow_non_requestable, false, object_name)==-1) {
-                  char buff[1024 + 1];
-                  centry_list_append_to_string(requests, buff, sizeof(buff) - 1);
-                  if (*buff && (buff[strlen(buff) - 1] == '\n')) {
-                     buff[strlen(buff) - 1] = 0;
+                  if (!isRQ) {
+                     char buff[1024 + 1];
+                     centry_list_append_to_string(requests, buff, sizeof(buff) - 1);
+                     if (*buff && (buff[strlen(buff) - 1] == '\n')) {
+                        buff[strlen(buff) - 1] = 0;
+                     }   
+                     schedd_mes_add(a->job_id, SCHEDD_INFO_CANNOTRUNINQUEUE_SSS, buff, object_name, reason_buf);
                   }   
-                  schedd_mes_add(a->job_id, SCHEDD_INFO_CANNOTRUNINQUEUE_SSS, buff, object_name, reason_buf);
                   DRETURN(DISPATCH_NEVER_CAT);
                }
                max_slots      = MIN(max_slots,      avail);
@@ -5927,12 +5936,14 @@
                &reason, allow_non_requestable, false, object_name);
 
       if (result == DISPATCH_NEVER_CAT || result == DISPATCH_NEVER_JOB) {
-         char buff[1024 + 1];
-         centry_list_append_to_string(requests, buff, sizeof(buff) - 1);
-         if (*buff && (buff[strlen(buff) - 1] == '\n')) {
-            buff[strlen(buff) - 1] = 0;
+         if (!isRQ) {
+            char buff[1024 + 1];
+            centry_list_append_to_string(requests, buff, sizeof(buff) - 1);
+            if (*buff && (buff[strlen(buff) - 1] == '\n')) {
+               buff[strlen(buff) - 1] = 0;
+            }   
+            schedd_mes_add(a->job_id, SCHEDD_INFO_CANNOTRUNINQUEUE_SSS, buff, object_name, reason_buf);
          }   
-         schedd_mes_add(a->job_id, SCHEDD_INFO_CANNOTRUNINQUEUE_SSS, buff, object_name, reason_buf);
       }
       
       switch (result) {
diff --exclude-from=/srv/pbuilder/result/sid/sge_ignore -Naur gridengine-6.2~beta2/source/libs/sgeobj/cull_parse_util.c gridengine-6.2/source/libs/sgeobj/cull_parse_util.c
--- gridengine-6.2~beta2/source/libs/sgeobj/cull_parse_util.c	2008-06-15 15:30:00.000000000 +0100
+++ gridengine-6.2/source/libs/sgeobj/cull_parse_util.c	2008-08-08 18:14:34.000000000 +0100
@@ -1219,7 +1219,7 @@
    hard_list = lCopyList("job_hard_sublist", lGetList(job, hard_field));
    if (soft_field) {
       soft_list = lCopyList("job_soft_sublist", lGetList(job, soft_field));
-   }   
+   }
 
    while ((ep = lGetElemStr(cmdline, SPA_switch, option))) {
       lp = NULL;
@@ -1228,30 +1228,26 @@
          if (!soft_field || lGetInt(ep, SPA_argval_lIntT) < 2) {
             if (!hard_list) {
                hard_list = lp;
-            }   
-            else {
+            } else {
                lAddList(hard_list, &lp);
-            }   
-         }
-         else {
+            }
+         } else {
             if (!soft_list) {
-                  soft_list = lp;
-            }      
-            else {
+               soft_list = lp;
+            } else {
                lAddList(soft_list, &lp);
-            }   
+            }
          }
       }
       lRemoveElem(cmdline, &ep);
-    }
+   }
 
-    lSetList(job, hard_field, hard_list);
-    if (soft_field) {
+   lSetList(job, hard_field, hard_list);
+   if (soft_field) {
       lSetList(job, soft_field, soft_list);
-    }  
+   }
 
-    DEXIT;
-    return 0;
+   DRETURN(0);
 }
 
 int parse_list_simple(
diff --exclude-from=/srv/pbuilder/result/sid/sge_ignore -Naur gridengine-6.2~beta2/source/libs/sgeobj/msg_sgeobjlib.h gridengine-6.2/source/libs/sgeobj/msg_sgeobjlib.h
--- gridengine-6.2~beta2/source/libs/sgeobj/msg_sgeobjlib.h	2008-06-15 15:30:00.000000000 +0100
+++ gridengine-6.2/source/libs/sgeobj/msg_sgeobjlib.h	2008-08-08 18:14:33.000000000 +0100
@@ -259,8 +259,6 @@
 
 #define MSG_JOB_NAMETOOLONG_I _MESSAGE(64353, _("job name too long, maximum allowed length is %d characters"))
 
-#define MSG_INVALIDJATASK_REQUEST _MESSAGE(64354, _("invalid task list in job start request"))
-
 #define MSG_INVALID_GDIL _MESSAGE(64355, _("invalid granted destination identifier list"))
 
 #define MSG_INVALID_QINSTANCE_NAME_S   _MESSAGE(64356, _("invalid queue instance name "SFQ))
diff --exclude-from=/srv/pbuilder/result/sid/sge_ignore -Naur gridengine-6.2~beta2/source/libs/sgeobj/sge_centry.c gridengine-6.2/source/libs/sgeobj/sge_centry.c
--- gridengine-6.2~beta2/source/libs/sgeobj/sge_centry.c	2008-06-15 15:30:00.000000000 +0100
+++ gridengine-6.2/source/libs/sgeobj/sge_centry.c	2008-08-08 18:14:33.000000000 +0100
@@ -182,12 +182,14 @@
    const char *name, *s;
    u_long32 type;
    double dval;
-   int ret;
+   int ret, allow_infinity;
 
    DENTER(CENTRY_LAYER, "centry_fill_and_check");
 
    name = lGetString(this_elem, CE_name);
    s = lGetString(this_elem, CE_stringval);
+   /* allow infinity for non-consumables only */
+   allow_infinity = lGetBool(this_elem, CE_consumable)?0:1;
 
    if (!s) {
       if (allow_empty_boolean && lGetUlong(this_elem, CE_valtype)==TYPE_BOO) {
@@ -206,9 +208,9 @@
       case TYPE_MEM:
       case TYPE_BOO:
       case TYPE_DOUBLE:
-         if (!parse_ulong_val(&dval, NULL, type, s, tmp, sizeof(tmp)-1)) {
+         if (!extended_parse_ulong_val(&dval, NULL, type, s, tmp, sizeof(tmp)-1, allow_infinity, false)) {
 /*             ERROR((SGE_EVENT, MSG_CPLX_WRONGTYPE_SSS, name, s, tmp)); */
-            answer_list_add_sprintf(answer_list, STATUS_EUNKNOWN, ANSWER_QUALITY_ERROR, MSG_CPLX_WRONGTYPE_SSS, name, s, tmp);
+            answer_list_add_sprintf(answer_list, STATUS_EUNKNOWN, ANSWER_QUALITY_ERROR, MSG_ATTRIB_XISNOTAY_SS, name, tmp);
             DRETURN(-1);
          }
          lSetDouble(this_elem, CE_doubleval, dval);
diff --exclude-from=/srv/pbuilder/result/sid/sge_ignore -Naur gridengine-6.2~beta2/source/libs/sgeobj/sge_conf.c gridengine-6.2/source/libs/sgeobj/sge_conf.c
--- gridengine-6.2~beta2/source/libs/sgeobj/sge_conf.c	2008-06-15 15:30:00.000000000 +0100
+++ gridengine-6.2/source/libs/sgeobj/sge_conf.c	2008-08-08 18:14:34.000000000 +0100
@@ -166,6 +166,14 @@
 static bool enable_windomacc = false;
 static bool enable_addgrp_kill = false;
 static u_long32 pdc_interval = 1;
+static char s_descriptors[100];
+static char h_descriptors[100];
+static char s_maxproc[100];
+static char h_maxproc[100];
+static char s_memorylocked[100];
+static char h_memorylocked[100];
+static char s_locks[100];
+static char h_locks[100];
 
 /* 
  * reporting params 
@@ -790,6 +798,14 @@
       sharelog_time = 0;
       log_consumables = false;
       enable_addgrp_kill = false;
+      strcpy(s_descriptors, "UNDEFINED");
+      strcpy(h_descriptors, "UNDEFINED");
+      strcpy(s_maxproc, "UNDEFINED");
+      strcpy(h_maxproc, "UNDEFINED");
+      strcpy(s_memorylocked, "UNDEFINED");
+      strcpy(h_memorylocked, "UNDEFINED");
+      strcpy(s_locks, "UNDEFINED");
+      strcpy(h_locks, "UNDEFINED");
 
       for (s=sge_strtok_r(execd_params, ",; ", &conf_context); s; s=sge_strtok_r(NULL, ",; ", &conf_context)) {
          if (parse_bool_param(s, "USE_QIDLE", &use_qidle)) {
@@ -890,6 +906,38 @@
             }
             continue;
          }
+         if (!strncasecmp(s, "S_DESCRIPTORS", sizeof("S_DESCRIPTORS")-1)) {
+            sge_strlcpy(s_descriptors, s+sizeof("S_DESCRIPTORS"), 100);
+            continue;
+         }
+         if (!strncasecmp(s, "H_DESCRIPTORS", sizeof("H_DESCRIPTORS")-1)) {
+            sge_strlcpy(h_descriptors, s+sizeof("H_DESCRIPTORS"), 100);
+            continue;
+         }
+         if (!strncasecmp(s, "S_MAXPROC", sizeof("S_MAXPROC")-1)) {
+            sge_strlcpy(s_maxproc, s+sizeof("S_MAXPROC"), 100);
+            continue;
+         }
+         if (!strncasecmp(s, "H_MAXPROC", sizeof("H_MAXPROC")-1)) {
+            sge_strlcpy(h_maxproc, s+sizeof("H_MAXPROC"), 100);
+            continue;
+         }
+         if (!strncasecmp(s, "S_MEMORYLOCKED", sizeof("S_MEMORYLOCKED")-1)) {
+            sge_strlcpy(s_memorylocked, s+sizeof("S_MEMORYLOCKED"), 100);
+            continue;
+         }
+         if (!strncasecmp(s, "H_MEMORYLOCKED", sizeof("H_MEMORYLOCKED")-1)) {
+            sge_strlcpy(h_memorylocked, s+sizeof("H_MEMORYLOCKED"), 100);
+            continue;
+         }
+         if (!strncasecmp(s, "S_LOCKS", sizeof("S_LOCKS")-1)) {
+            sge_strlcpy(s_locks, s+sizeof("S_LOCKS"), 100);
+            continue;
+         }
+         if (!strncasecmp(s, "H_LOCKS", sizeof("H_LOCKS")-1)) {
+            sge_strlcpy(h_locks, s+sizeof("H_LOCKS"), 100);
+            continue;
+         }
       }
       SGE_UNLOCK(LOCK_MASTER_CONF, LOCK_WRITE);
       sge_free_saved_vars(conf_context);
@@ -2266,3 +2314,83 @@
    SGE_UNLOCK(LOCK_MASTER_CONF, LOCK_READ);
    DRETURN(deletion_time);
 }
+
+void mconf_get_h_descriptors(char **pret) {
+   DENTER(BASIS_LAYER, "mconf_get_h_descriptors");
+   SGE_LOCK(LOCK_MASTER_CONF, LOCK_READ);
+
+   *pret = strdup(h_descriptors);
+   
+   SGE_UNLOCK(LOCK_MASTER_CONF, LOCK_READ);
+   DRETURN_VOID;
+}
+
+void mconf_get_s_descriptors(char **pret) {
+   DENTER(BASIS_LAYER, "mconf_get_s_descriptors");
+   SGE_LOCK(LOCK_MASTER_CONF, LOCK_READ);
+
+   *pret = strdup(s_descriptors);
+   
+   SGE_UNLOCK(LOCK_MASTER_CONF, LOCK_READ);
+   DRETURN_VOID;
+}
+
+void mconf_get_h_maxproc(char **pret) {
+   DENTER(BASIS_LAYER, "mconf_get_h_maxproc");
+   SGE_LOCK(LOCK_MASTER_CONF, LOCK_READ);
+
+   *pret = strdup(h_maxproc);
+   
+   SGE_UNLOCK(LOCK_MASTER_CONF, LOCK_READ);
+   DRETURN_VOID;
+}
+
+void mconf_get_s_maxproc(char **pret) {
+   DENTER(BASIS_LAYER, "mconf_get_s_maxproc");
+   SGE_LOCK(LOCK_MASTER_CONF, LOCK_READ);
+
+   *pret = strdup(s_maxproc);
+   
+   SGE_UNLOCK(LOCK_MASTER_CONF, LOCK_READ);
+   DRETURN_VOID;
+}
+
+void mconf_get_h_memorylocked(char **pret) {
+   DENTER(BASIS_LAYER, "mconf_get_h_memorylocked");
+   SGE_LOCK(LOCK_MASTER_CONF, LOCK_READ);
+
+   *pret = strdup(h_memorylocked);
+   
+   SGE_UNLOCK(LOCK_MASTER_CONF, LOCK_READ);
+   DRETURN_VOID;
+}
+
+void mconf_get_s_memorylocked(char **pret) {
+   DENTER(BASIS_LAYER, "mconf_get_s_memorylocked");
+   SGE_LOCK(LOCK_MASTER_CONF, LOCK_READ);
+
+   *pret = strdup(s_memorylocked);
+   
+   SGE_UNLOCK(LOCK_MASTER_CONF, LOCK_READ);
+   DRETURN_VOID;
+}
+
+void mconf_get_h_locks(char **pret) {
+   DENTER(BASIS_LAYER, "mconf_get_h_locks");
+   SGE_LOCK(LOCK_MASTER_CONF, LOCK_READ);
+
+   *pret = strdup(h_locks);
+   
+   SGE_UNLOCK(LOCK_MASTER_CONF, LOCK_READ);
+   DRETURN_VOID;
+}
+
+void mconf_get_s_locks(char **pret) {
+   DENTER(BASIS_LAYER, "mconf_get_s_locks");
+   SGE_LOCK(LOCK_MASTER_CONF, LOCK_READ);
+
+   *pret = strdup(s_locks);
+   
+   SGE_UNLOCK(LOCK_MASTER_CONF, LOCK_READ);
+   DRETURN_VOID;
+}
diff --exclude-from=/srv/pbuilder/result/sid/sge_ignore -Naur gridengine-6.2~beta2/source/libs/sgeobj/sge_conf.h gridengine-6.2/source/libs/sgeobj/sge_conf.h
--- gridengine-6.2~beta2/source/libs/sgeobj/sge_conf.h	2008-06-15 15:30:00.000000000 +0100
+++ gridengine-6.2/source/libs/sgeobj/sge_conf.h	2008-08-08 18:14:33.000000000 +0100
@@ -39,6 +39,7 @@
 #define REPRIORITIZE "reprioritize"
 
 #define GID_RANGE_NOT_ALLOWED_ID 100
+#define RLIMIT_UNDEFINED -9999
 
 typedef int (*tDaemonizeFunc)(void *ctx);
 
@@ -141,5 +142,13 @@
 u_long32 mconf_get_pdc_interval(void);
 bool mconf_get_enable_reschedule_kill(void);
 bool mconf_get_enable_reschedule_slave(void);
+void mconf_get_h_descriptors(char **pret);
+void mconf_get_s_descriptors(char **pret);
+void mconf_get_h_maxproc(char **pret);
+void mconf_get_s_maxproc(char **pret);
+void mconf_get_h_memorylocked(char **pret);
+void mconf_get_s_memorylocked(char **pret);
+void mconf_get_h_locks(char **pret);
+void mconf_get_s_locks(char **pret);
 
 #endif /* __SGE_CONF_H */
diff --exclude-from=/srv/pbuilder/result/sid/sge_ignore -Naur gridengine-6.2~beta2/source/libs/sgeobj/sge_host.c gridengine-6.2/source/libs/sgeobj/sge_host.c
--- gridengine-6.2~beta2/source/libs/sgeobj/sge_host.c	2008-06-15 15:30:00.000000000 +0100
+++ gridengine-6.2/source/libs/sgeobj/sge_host.c	2008-08-08 18:14:33.000000000 +0100
@@ -58,23 +58,32 @@
    lListElem *ret = NULL;
    
    DENTER(TOP_LAYER, "host_list_locate");
-   if (hostname != NULL && host_list != NULL) {
-      const lListElem *element = lFirst(host_list);
-
-      if (element != NULL) {
-         int nm = NoName;
-
-         if (object_has_type(element, EH_Type)) {
-            nm = object_get_primary_key(EH_Type);
-         } else if (object_has_type(element, AH_Type)) {
-            nm = object_get_primary_key(AH_Type);
-         } else if (object_has_type(element, SH_Type)) {
-            nm = object_get_primary_key(SH_Type);
+   if (host_list != NULL) {
+      if (hostname != NULL) {
+         const lListElem *element = lFirst(host_list);
+
+         if (element != NULL) {
+            int nm = NoName;
+
+            if (object_has_type(element, EH_Type)) {
+               nm = object_get_primary_key(EH_Type);
+            } else if (object_has_type(element, AH_Type)) {
+               nm = object_get_primary_key(AH_Type);
+            } else if (object_has_type(element, SH_Type)) {
+               nm = object_get_primary_key(SH_Type);
+            }
+            ret = lGetElemHost(host_list, nm, hostname);
          }
-         ret = lGetElemHost(host_list, nm, hostname);
+      } else {
+         CRITICAL((SGE_EVENT, MSG_SGETEXT_NULLPTRPASSED_S, SGE_FUNC));
       }
    } else {
-      CRITICAL((SGE_EVENT, MSG_SGETEXT_NULLPTRPASSED_S, SGE_FUNC));
+      /*
+       * This is a normal case and no error
+       * if e.g. someone tries to find a element at qmaster startup to 
+       * check if a certain element should be added
+       */
+      ret = NULL;
    }
    
    DRETURN(ret);
@@ -274,8 +283,7 @@
    DENTER(TOP_LAYER, "sge_resolve_hostname");
 
    if (hostname == NULL) {
-      DEXIT;
-      return CL_RETVAL_PARAMS;
+      DRETURN(CL_RETVAL_PARAMS);
    }
 
    /* 
@@ -338,8 +346,7 @@
       }
    }
 
-   DEXIT;
-   return ret;
+   DRETURN(ret);
 }
 
 bool
@@ -349,6 +356,7 @@
    bool ret = false;
 
    DENTER(TOP_LAYER, "host_is_centry_a_complex_value");
+
    if (this_elem != NULL) {  
       const char *name = lGetString(centry, CE_name);
       const lList *ce_values = lGetList(this_elem, EH_consumable_config_list);
@@ -364,8 +372,7 @@
          ret = true;
       }  
    }
-   DEXIT;
-   return ret;
+   DRETURN(ret);
 }
 
 /****** sgeobj/host/host_list_merge() ******************************************
@@ -400,13 +407,17 @@
    DENTER(TOP_LAYER, "host_list_merge");
    
    if (this_list != NULL) {
-      const lListElem *global_host;
+      lListElem *global_host;
 
       /* we merge global settings into host settings */
       global_host = lGetElemHost(this_list, EH_name, SGE_GLOBAL_NAME);
       if (global_host != NULL) {
          lListElem *host;
 
+         /* for the global host, merged_report_variables == report_variables */
+         lSetList(global_host, EH_merged_report_variables,
+                  lCopyList("", lGetList(global_host, EH_report_variables)));
+
          /* do merge for all hosts except global */
          for_each (host, this_list) {
             if (host != global_host) {
@@ -460,8 +471,7 @@
 
       /* if we have a local list: use this one */
       if (local_list != NULL && lGetNumberOfElem(local_list) != 0) {
-         lSetList(host, EH_merged_report_variables, 
-                  lCopyList("", local_list));
+         lSetList(host, EH_merged_report_variables, lCopyList("", local_list));
       } else {
          const lList *global_list;
       
@@ -479,7 +489,6 @@
       }
    }
    
-   DEXIT;
-   return ret;
+   DRETURN(ret);
 }
 
diff --exclude-from=/srv/pbuilder/result/sid/sge_ignore -Naur gridengine-6.2~beta2/source/libs/sgeobj/sge_job.c gridengine-6.2/source/libs/sgeobj/sge_job.c
--- gridengine-6.2~beta2/source/libs/sgeobj/sge_job.c	2008-06-15 15:30:00.000000000 +0100
+++ gridengine-6.2/source/libs/sgeobj/sge_job.c	2008-08-08 18:14:33.000000000 +0100
@@ -289,7 +289,7 @@
 *     has to be called to free allocated memory.
 *
 *  INPUTS
-*     const lListElem *job   - JB_Type 
+*     const lListElem *job    - JB_Type 
 *     lList *id_list[16]      - NULL initialized pointer array 
 *     u_long32 hold_state[16] - Array for hold state combinations 
 *
@@ -431,7 +431,7 @@
 *
 *  SYNOPSIS
 *     void job_destroy_hold_id_lists(const lListElem *job, 
-*                                    lList *id_list[8]) 
+*                                    lList *id_list[16]) 
 *
 *  FUNCTION
 *     This function frees all memory allocated by a previous call of 
@@ -439,7 +439,7 @@
 *
 *  INPUTS
 *     const lListElem *job - JB_Type 
-*     lList *id_list[8]    - array of RN_Type lists
+*     lList *id_list[16]   - array of RN_Type lists
 *
 *  SEE ALSO
 *     sgeobj/job/job_create_hold_id_lists 
@@ -599,7 +599,7 @@
                                   lGetList(job, JB_ja_a_h_ids));
 
    ret += range_list_get_number_of_ids(lGetList(job, JB_ja_n_h_ids));
-   ret += range_list_get_number_of_ids(uos_ids);
+   ret += range_list_get_number_of_ids(uosa_ids);
 
    lFreeList(&uosa_ids);
    lFreeList(&uos_ids);
@@ -1310,7 +1310,7 @@
 *     const lList *pe_list - PE_Type list with all existing PEs 
 *
 *  RESULT
-*     bool - treu or false
+*     bool - true or false
 *
 *  SEE ALSO
 *     sgeobj/job/job_is_array()
@@ -1865,7 +1865,7 @@
 *  FUNCTION
 *     Test following elements of "job" whether they are correct:
 *        JB_ja_structure, JB_ja_n_h_ids, JB_ja_u_h_ids, 
-*        JB_ja_s_h_ids, JB_ja_o_h_ids, JB_ja_z_ids
+*        JB_ja_s_h_ids, JB_ja_o_h_ids, JB_ja_a_h_ids, JB_ja_z_ids
 *     The function will try to correct errors within this lists. If
 *     this is not possible an error will be returned in "answer_list".
 *      
@@ -1890,6 +1890,7 @@
          JB_ja_u_h_ids,
          JB_ja_s_h_ids,
          JB_ja_o_h_ids,
+         JB_ja_a_h_ids,
          JB_ja_z_ids,
          -1
       };
@@ -3484,98 +3485,6 @@
    DRETURN(ret);
 }
 
-/****** sge_job/job_verify_execd_job() *****************************************
-*  NAME
-*     job_verify_execd_job() -- verify a job entering execd
-*
-*  SYNOPSIS
-*     bool 
-*     job_verify_execd_job(const lListElem *job, lList **answer_list) 
-*
-*  FUNCTION
-*     Verifies a job object entering execd.
-*     Does generic tests by calling job_verify, like verifying the cull
-*     structure, and makes sure a number of job attributes are set
-*     correctly.
-*
-*  INPUTS
-*     const lListElem *job - the job to verify
-*     lList **answer_list  - answer list to pass back error messages
-*
-*  RESULT
-*     bool - true on success,
-*            false on error with error message in answer_list
-*
-*  NOTES
-*     MT-NOTE: job_verify_execd_job() is MT safe 
-*
-*  BUGS
-*     The function is far from being complete.
-*     Currently, only the CULL structure is verified, not the contents.
-*
-*  SEE ALSO
-*     sge_job/job_verify()
-*******************************************************************************/
-bool
-job_verify_execd_job(const lListElem *job, lList **answer_list)
-{
-   bool ret = true;
-
-   DENTER(TOP_LAYER, "job_verify_execd_job");
-
-   ret = job_verify(job, answer_list);
-
-   /* 
-    * A job entering execd must have some additional properties:
-    *    - correct state
-    *    - JB_job_number > 0
-    *    - JB_job_name != NULL
-    *    - JB_exec_file etc. ???
-    *    - JB_submission_time, JB_execution_time??
-    *    - JB_owner != NULL
-    *    - JB_cwd != NULL??
-    */
-
-   if (ret) {
-      ret = object_verify_ulong_not_null(job, answer_list, JB_job_number);
-   }
-
-   if (ret) {
-      ret = object_verify_string_not_null(job, answer_list, JB_job_name);
-   }
-
-   if (ret) {
-      ret = object_verify_string_not_null(job, answer_list, JB_owner);
-   }
-
-   if (ret) {
-      const lListElem *ckpt = lGetObject(job, JB_checkpoint_object);
-      if (ckpt != NULL) {
-         if (ckpt_validate(ckpt, answer_list) != STATUS_OK) {
-            ret = false;
-         }
-      }
-   }
-
-   /* for job execution, we need exactly one ja task */
-   if (ret) {
-      const lList *ja_tasks = lGetList(job, JB_ja_tasks);
-
-      if (ja_tasks == NULL || lGetNumberOfElem(ja_tasks) != 1) {
-         answer_list_add_sprintf(answer_list, STATUS_ESYNTAX, ANSWER_QUALITY_ERROR, 
-                           MSG_INVALIDJATASK_REQUEST);
-         ret = false;
-      }
-
-      /* verify the ja task structure */
-      if (ret) {
-         ret = ja_task_verify_execd_job(lFirst(ja_tasks), answer_list);
-      }
-   }
-
-   DRETURN(ret);
-}
-
 /****** sge_job/job_get_wallclock_limit() **************************************
 *  NAME
 *     job_get_wallclock_limit() -- Computes jobs wallclock limit
diff --exclude-from=/srv/pbuilder/result/sid/sge_ignore -Naur gridengine-6.2~beta2/source/libs/sgeobj/sge_job.h gridengine-6.2/source/libs/sgeobj/sge_job.h
--- gridengine-6.2~beta2/source/libs/sgeobj/sge_job.h	2008-06-15 15:30:00.000000000 +0100
+++ gridengine-6.2/source/libs/sgeobj/sge_job.h	2008-08-08 18:14:33.000000000 +0100
@@ -302,7 +302,6 @@
 
 bool job_verify(const lListElem *job, lList **answer_list);
 bool job_verify_submitted_job(const lListElem *job, lList **answer_list);
-bool job_verify_execd_job(const lListElem *job, lList **answer_list);
 
 bool job_get_wallclock_limit(u_long32 *limit, const lListElem *jep);
 
diff --exclude-from=/srv/pbuilder/result/sid/sge_ignore -Naur gridengine-6.2~beta2/source/libs/sgeobj/sge_qref.c gridengine-6.2/source/libs/sgeobj/sge_qref.c
--- gridengine-6.2~beta2/source/libs/sgeobj/sge_qref.c	2008-06-15 15:30:00.000000000 +0100
+++ gridengine-6.2/source/libs/sgeobj/sge_qref.c	2008-08-08 18:14:33.000000000 +0100
@@ -418,7 +418,7 @@
 *  INPUTS
 *     const char *qref_pattern - a wildcard pattern as defined for -q qref_list
 *     const char *cqname       - cluster queue name
-*     const char *hostname     - exeuction hostname (may be NULL)
+*     const char *hostname     - execution hostname (may be NULL)
 *     const lList *hgroup_list - host group list
 *
 *  RESULT
@@ -794,7 +794,7 @@
             lFreeList(&qref_list);
             lFreeList(&resolved_qref_list);
             if (!found_matching_qinstance) {
-               ERROR((SGE_EVENT, MSG_QREF_QUNKNOWN_S, qref_pattern));
+               ERROR((SGE_EVENT, MSG_QREF_QUNKNOWN_S, qref_pattern == NULL ? "" : qref_pattern));
                answer_list_add(answer_list, SGE_EVENT,
                                STATUS_EUNKNOWN, ANSWER_QUALITY_ERROR);
                ret = false;
@@ -807,8 +807,7 @@
          ret = false;
       }
    }
-   DEXIT;
-   return ret;
+   DRETURN(ret);
 }
 
 void
diff --exclude-from=/srv/pbuilder/result/sid/sge_ignore -Naur gridengine-6.2~beta2/source/libs/sgeobj/sge_resource_quota.c gridengine-6.2/source/libs/sgeobj/sge_resource_quota.c
--- gridengine-6.2~beta2/source/libs/sgeobj/sge_resource_quota.c	2008-06-15 15:30:01.000000000 +0100
+++ gridengine-6.2/source/libs/sgeobj/sge_resource_quota.c	2008-08-08 18:14:34.000000000 +0100
@@ -363,6 +363,12 @@
 
             lSetString(limit, RQRL_name, lGetString(centry, CE_name));
 
+            if (strval == NULL) {
+               answer_list_add_sprintf(answer_list, STATUS_ESYNTAX, ANSWER_QUALITY_ERROR, MSG_RESOURCEQUOTA_NORULES);
+               ret = false;
+               break;
+            }
+
             if (strchr(strval, '$') != NULL) {
                if (lGetUlong(rule, RQR_level) == RQR_HOST || lGetUlong(rule, RQR_level) == RQR_QUEUEI) {
                   /* the value is a dynamical limit */
diff --exclude-from=/srv/pbuilder/result/sid/sge_ignore -Naur gridengine-6.2~beta2/source/libs/spool/berkeleydb/sge_bdb.c gridengine-6.2/source/libs/spool/berkeleydb/sge_bdb.c
--- gridengine-6.2~beta2/source/libs/spool/berkeleydb/sge_bdb.c	2008-06-15 15:30:01.000000000 +0100
+++ gridengine-6.2/source/libs/spool/berkeleydb/sge_bdb.c	2008-08-08 18:14:34.000000000 +0100
@@ -28,7 +28,13 @@
  *   All Rights Reserved.
  *
  ************************************************************************/
-/*___INFO__MARK_END__*/                                   
+/*___INFO__MARK_END__*/ 
+
+#ifndef NO_SGE_COMPILE_DEBUG
+#define NO_SGE_COMPILE_DEBUG
+#endif
+
+#define BDB_LAYER BASIS_LAYER
 
 #include <errno.h>
 #include <string.h>
@@ -110,7 +116,7 @@
    const char *version;
    int major, minor;
 
-   DENTER(TOP_LAYER, "spool_berkeleydb_check_version");
+   DENTER(BDB_LAYER, "spool_berkeleydb_check_version");
    
    version = db_version(&major, &minor, NULL);
 
@@ -171,7 +177,7 @@
 
    DB_ENV *env = NULL;
 
-   DENTER(TOP_LAYER, "spool_berkeleydb_create_environment");
+   DENTER(BDB_LAYER, "spool_berkeleydb_create_environment");
 
    server = bdb_get_server(info);
    path   = bdb_get_path(info);
@@ -376,7 +382,7 @@
    bool ret = true;
    bdb_database i;
 
-   DENTER(TOP_LAYER, "spool_berkeleydb_open_database");
+   DENTER(BDB_LAYER, "spool_berkeleydb_open_database");
 
    for (i = BDB_CONFIG_DB; i < BDB_ALL_DBS && ret; i++) {
       DB_ENV *env;
@@ -496,7 +502,7 @@
    dstring dbname_dstring = DSTRING_INIT;
    const char *dbname;
 
-   DENTER(TOP_LAYER, "spool_berkeleydb_close_database");
+   DENTER(BDB_LAYER, "spool_berkeleydb_close_database");
 
    sge_dstring_init(&dbname_dstring, dbname_buffer, sizeof(dbname_buffer));
    dbname = bdb_get_dbname(info, &dbname_dstring);
@@ -599,7 +605,7 @@
    DB_ENV *env;
    DB_TXN *txn;
 
-   DENTER(TOP_LAYER, "spool_berkeleydb_start_transaction");
+   DENTER(BDB_LAYER, "spool_berkeleydb_start_transaction");
 
    env = bdb_get_env(info);
    txn = bdb_get_txn(info);
@@ -665,7 +671,7 @@
    DB_ENV *env;
    DB_TXN *txn;
 
-   DENTER(TOP_LAYER, "spool_berkeleydb_end_transaction");
+   DENTER(BDB_LAYER, "spool_berkeleydb_end_transaction");
 
    env = bdb_get_env(info);
    txn = bdb_get_txn(info);
@@ -727,7 +733,7 @@
 {
    bool ret = true;
 
-   DENTER(TOP_LAYER, "spool_berkeleydb_trigger");
+   DENTER(BDB_LAYER, "spool_berkeleydb_trigger");
 
    if (bdb_get_next_clear(info) <= trigger) {
       /* 
@@ -770,7 +776,7 @@
    DBT key_dbt, data_dbt;
    DBC *dbc;
 
-   DENTER(TOP_LAYER, "spool_berkeleydb_read_list");
+   DENTER(BDB_LAYER, "spool_berkeleydb_read_list");
 
    db  = bdb_get_db(info, database);
    txn = bdb_get_txn(info);
@@ -893,7 +899,7 @@
    bool ret = true;
    lList *tmp_list = NULL;
 
-   DENTER(TOP_LAYER, "spool_berkeleydb_write_object");
+   DENTER(BDB_LAYER, "spool_berkeleydb_write_object");
 
    /* do not spool free elems. If a free elem is passed, put a copy 
     * into a temporary list and spool this copy.
@@ -991,7 +997,7 @@
 {
    bool ret = true;
 
-   DENTER(TOP_LAYER, "spool_berkeleydb_write_string");
+   DENTER(BDB_LAYER, "spool_berkeleydb_write_string");
 
    {
       int dbret;
@@ -1200,7 +1206,7 @@
    DB *db;
    DB_TXN *txn;
 
-   DENTER(TOP_LAYER, "spool_berkeleydb_delete_object");
+   DENTER(BDB_LAYER, "spool_berkeleydb_delete_object");
 
    db = bdb_get_db(info, database);
    txn = bdb_get_txn(info);
@@ -1622,7 +1628,7 @@
    bool ret = true;
    DB_ENV *env;
 
-   DENTER(TOP_LAYER, "spool_berkeleydb_check_reopen_database");
+   DENTER(BDB_LAYER, "spool_berkeleydb_check_reopen_database");
 
    env = bdb_get_env(info);
 
@@ -1658,7 +1664,7 @@
    DBT key_dbt, data_dbt;
    DBC *dbc;
 
-   DENTER(TOP_LAYER, "spool_berkeleydb_read_keys");
+   DENTER(BDB_LAYER, "spool_berkeleydb_read_keys");
 
    db  = bdb_get_db(info, database);
    txn = bdb_get_txn(info);
@@ -1747,7 +1753,7 @@
 
    DBT key_dbt, data_dbt;
 
-   DENTER(TOP_LAYER, "spool_berkeleydb_read_object");
+   DENTER(BDB_LAYER, "spool_berkeleydb_read_object");
 
    db  = bdb_get_db(info, database);
    txn = bdb_get_txn(info);
@@ -1830,7 +1836,7 @@
 
    DBT key_dbt, data_dbt;
 
-   DENTER(TOP_LAYER, "spool_berkeleydb_read_string");
+   DENTER(BDB_LAYER, "spool_berkeleydb_read_string");
 
    db  = bdb_get_db(info, database);
    txn = bdb_get_txn(info);
@@ -1872,7 +1878,7 @@
    bool ret = true;
    DB_ENV *env;
 
-   DENTER(TOP_LAYER, "spool_berkeleydb_clear_log");
+   DENTER(BDB_LAYER, "spool_berkeleydb_clear_log");
 
    /* check connection */
    env = bdb_get_env(info);
@@ -1937,7 +1943,7 @@
    bool ret = true;
    DB_ENV *env;
 
-   DENTER(TOP_LAYER, "spool_berkeleydb_trigger_rpc");
+   DENTER(BDB_LAYER, "spool_berkeleydb_trigger_rpc");
 
    /* check connection */
    env = bdb_get_env(info);
@@ -1973,7 +1979,7 @@
 {
    bool ret = true;
 
-   DENTER(TOP_LAYER, "spool_berkeleydb_checkpoint");
+   DENTER(BDB_LAYER, "spool_berkeleydb_checkpoint");
 
    /* only necessary for local spooling */
    if (bdb_get_server(info) == NULL) {
diff --exclude-from=/srv/pbuilder/result/sid/sge_ignore -Naur gridengine-6.2~beta2/source/libs/spool/berkeleydb/sge_spooling_berkeleydb.c gridengine-6.2/source/libs/spool/berkeleydb/sge_spooling_berkeleydb.c
--- gridengine-6.2~beta2/source/libs/spool/berkeleydb/sge_spooling_berkeleydb.c	2008-06-15 15:30:01.000000000 +0100
+++ gridengine-6.2/source/libs/spool/berkeleydb/sge_spooling_berkeleydb.c	2008-08-08 18:14:34.000000000 +0100
@@ -30,6 +30,12 @@
  ************************************************************************/
 /*___INFO__MARK_END__*/                                   
 
+#ifndef NO_SGE_COMPILE_DEBUG
+#define NO_SGE_COMPILE_DEBUG
+#endif
+
+#define BDB_LAYER BASIS_LAYER
+
 #include <errno.h>
 #include <string.h>
 #include <time.h>
@@ -115,7 +121,7 @@
 {
    lListElem *context = NULL;
 
-   DENTER(TOP_LAYER, "spool_berkeleydb_create_context");
+   DENTER(BDB_LAYER, "spool_berkeleydb_create_context");
 
    /* check input parameter */
    if (args != NULL) {
@@ -211,7 +217,7 @@
    bool ret = true;
    bdb_info info;
 
-   DENTER(TOP_LAYER, "spool_berkeleydb_default_startup_func");
+   DENTER(BDB_LAYER, "spool_berkeleydb_default_startup_func");
 
    info = (bdb_info)lGetRef(rule, SPR_clientdata);
 
@@ -268,7 +274,7 @@
 
    bdb_info info;
 
-   DENTER(TOP_LAYER, "spool_berkeleydb_default_shutdown_func");
+   DENTER(BDB_LAYER, "spool_berkeleydb_default_shutdown_func");
 
    info = (bdb_info)lGetRef(rule, SPR_clientdata);
 
@@ -333,7 +339,7 @@
 
    bdb_info info;
 
-   DENTER(TOP_LAYER, "spool_berkeleydb_default_maintenance_func");
+   DENTER(BDB_LAYER, "spool_berkeleydb_default_maintenance_func");
 
    info = (bdb_info)lGetRef(rule, SPR_clientdata);
 
@@ -395,7 +401,7 @@
    bool ret = true;
    bdb_info info;
 
-   DENTER(TOP_LAYER, "spool_berkeleydb_trigger_func");
+   DENTER(BDB_LAYER, "spool_berkeleydb_trigger_func");
 
    info = (bdb_info)lGetRef(rule, SPR_clientdata);
    if (info == NULL) {
@@ -457,7 +463,7 @@
 
    bdb_info info;
 
-   DENTER(TOP_LAYER, "spool_berkeleydb_default_transaction_func");
+   DENTER(BDB_LAYER, "spool_berkeleydb_default_transaction_func");
 
    info = (bdb_info)lGetRef(rule, SPR_clientdata);
    if (info == NULL) {
@@ -549,7 +555,7 @@
 
    bdb_info info;
 
-   DENTER(TOP_LAYER, "spool_berkeleydb_default_list_func");
+   DENTER(BDB_LAYER, "spool_berkeleydb_default_list_func");
 
    info = (bdb_info)lGetRef(rule, SPR_clientdata);
    descr = object_type_get_descr(object_type);
@@ -782,7 +788,7 @@
 
    bdb_info info;
 
-   DENTER(TOP_LAYER, "spool_berkeleydb_default_read_func");
+   DENTER(BDB_LAYER, "spool_berkeleydb_default_read_func");
 
    info = (bdb_info)lGetRef(rule, SPR_clientdata);
 
@@ -892,7 +898,7 @@
    bool local_transaction = false; /* did we start a transaction? */
    bdb_info info;
 
-   DENTER(TOP_LAYER, "spool_berkeleydb_default_write_func");
+   DENTER(BDB_LAYER, "spool_berkeleydb_default_write_func");
 
    DPRINTF(("spool_berkeleydb_default_write_func called for %s with key %s\n",
             object_type_get_name(object_type), key != NULL ? key : "<null>"));
@@ -1057,7 +1063,7 @@
    char dbkey_buffer[MAX_STRING_SIZE];
    const char *dbkey;
 
-   DENTER(TOP_LAYER, "spool_berkeleydb_default_delete_func");
+   DENTER(BDB_LAYER, "spool_berkeleydb_default_delete_func");
 
    sge_dstring_init(&dbkey_dstring, dbkey_buffer, sizeof(dbkey_buffer));
    info = (bdb_info)lGetRef(rule, SPR_clientdata);
@@ -1161,7 +1167,7 @@
    const char *delimiter = ",; ";
    bdb_info info;
 
-   DENTER(TOP_LAYER, "spool_berkeleydb_option_func");
+   DENTER(BDB_LAYER, "spool_berkeleydb_option_func");
 
    info = (bdb_info)lGetRef(rule, SPR_clientdata);
 
diff --exclude-from=/srv/pbuilder/result/sid/sge_ignore -Naur gridengine-6.2~beta2/source/libs/spool/flatfile/sge_flatfile.c gridengine-6.2/source/libs/spool/flatfile/sge_flatfile.c
--- gridengine-6.2~beta2/source/libs/spool/flatfile/sge_flatfile.c	2008-06-15 15:30:01.000000000 +0100
+++ gridengine-6.2/source/libs/spool/flatfile/sge_flatfile.c	2008-08-08 18:14:34.000000000 +0100
@@ -85,6 +85,7 @@
 /* uti */
 #include "uti/sge_spool.h"
 #include "uti/sge_unistd.h"
+#include "uti/sge_profiling.h"
 #include "sge_all_listsL.h"
 
 const spool_flatfile_instr qconf_sub_name_value_space_sfi = 
@@ -1225,6 +1226,8 @@
 
    SGE_CHECK_POINTER_NULL(data, answer_list);
 
+   PROF_START_MEASUREMENT(SGE_PROF_SPOOLINGIO);
+
    /* open/get filehandle */
    fd = spool_flatfile_open_file(answer_list, destination, filepath, &result);
 #ifdef USE_FOPEN
@@ -1233,6 +1236,7 @@
    if (fd == -1) {
 #endif
       /* message generated in spool_flatfile_open_file */
+      PROF_STOP_MEASUREMENT(SGE_PROF_SPOOLINGIO);
       DRETURN(NULL);
    }
 
@@ -1249,6 +1253,7 @@
       spool_flatfile_close_file(answer_list, fd, result, destination);
       unlink(filepath);
       FREE(result);
+      PROF_STOP_MEASUREMENT(SGE_PROF_SPOOLINGIO);
       DRETURN(NULL);
    }
 
@@ -1257,8 +1262,10 @@
       /* message generated in spool_flatfile_close_file */
       unlink(filepath);
       FREE(result);
+      PROF_STOP_MEASUREMENT(SGE_PROF_SPOOLINGIO);
       DRETURN(NULL);
    }
+   PROF_STOP_MEASUREMENT(SGE_PROF_SPOOLINGIO);
 
    DRETURN(result);
 }
@@ -1970,7 +1977,8 @@
                                        ANSWER_QUALITY_ERROR,
                                        MSG_MUST_BE_POSITIVE_VALUE_S,
                                        fields[field_index].name);
-                  return;
+                  sge_dstring_free(&buffer);
+                  DRETURN_VOID;
                }
             }
             if (object_parse_field_from_string(*object, answer_list, nm, 
@@ -2163,8 +2171,7 @@
 
    /* cleanup */
    sge_dstring_free(&buffer);
-   DEXIT;
-   return;
+   DRETURN_VOID;
 }
 
 /****** spool/flatfile/spool_flatfile_read_list() ***********************
diff --exclude-from=/srv/pbuilder/result/sid/sge_ignore -Naur gridengine-6.2~beta2/source/libs/spool/flatfile/sge_flatfile_obj.c gridengine-6.2/source/libs/spool/flatfile/sge_flatfile_obj.c
--- gridengine-6.2~beta2/source/libs/spool/flatfile/sge_flatfile_obj.c	2008-06-15 15:30:01.000000000 +0100
+++ gridengine-6.2/source/libs/spool/flatfile/sge_flatfile_obj.c	2008-08-08 18:14:34.000000000 +0100
@@ -1101,17 +1101,18 @@
 static int read_CQ_ulng_attr_list(lListElem *ep, int nm, const char *buffer, lList **alp)
 {
    lList *lp = NULL;
-   
+
    if (!ulng_attr_list_parse_from_string(&lp, alp, buffer,
-                                          HOSTATTR_ALLOW_AMBIGUITY)) {
+                                         HOSTATTR_ALLOW_AMBIGUITY)) {
+      lFreeList(&lp);
       return 0;
    }
-   
+
    if (lp != NULL) {
       lSetList(ep, nm, lp);
       return 1;
    }
-   
+
    return 0;
 }
 
@@ -1127,17 +1128,18 @@
                                      lList **alp)
 {
    lList *lp = NULL;
-   
+
    if (!celist_attr_list_parse_from_string(&lp, alp, buffer,
                                           HOSTATTR_ALLOW_AMBIGUITY)) {
+      lFreeList(&lp);
       return 0;
    }
-   
+
    if (lp != NULL) {
       lSetList(ep, nm, lp);
       return 1;
    }
-   
+
    return 0;
 }
 
@@ -1156,6 +1158,7 @@
    
    if (!inter_attr_list_parse_from_string(&lp, alp, buffer,
                                           HOSTATTR_ALLOW_AMBIGUITY)) {
+      lFreeList(&lp);
       return 0;
    }
    
@@ -1182,6 +1185,7 @@
    
    if (!str_attr_list_parse_from_string(&lp, alp, buffer,
                                           HOSTATTR_ALLOW_AMBIGUITY)) {
+      lFreeList(&lp);
       return 0;
    }
    
@@ -1208,6 +1212,7 @@
    
    if (!qtlist_attr_list_parse_from_string(&lp, alp, buffer,
                                           HOSTATTR_ALLOW_AMBIGUITY)) {
+      lFreeList(&lp);
       return 0;
    }
    
@@ -1234,6 +1239,7 @@
    
    if (!strlist_attr_list_parse_from_string(&lp, alp, buffer,
                                           HOSTATTR_ALLOW_AMBIGUITY)) {
+      lFreeList(&lp);
       return 0;
    }
    
@@ -1260,6 +1266,7 @@
    
    if (!bool_attr_list_parse_from_string(&lp, alp, buffer,
                                           HOSTATTR_ALLOW_AMBIGUITY)) {
+      lFreeList(&lp);
       return 0;
    }
    
@@ -1286,6 +1293,7 @@
    
    if (!usrlist_attr_list_parse_from_string(&lp, alp, buffer,
                                           HOSTATTR_ALLOW_AMBIGUITY)) {
+      lFreeList(&lp);
       return 0;
    }
    
@@ -1312,6 +1320,7 @@
    
    if (!solist_attr_list_parse_from_string(&lp, alp, buffer,
                                           HOSTATTR_ALLOW_AMBIGUITY)) {
+      lFreeList(&lp);
       return 0;
    }
    
@@ -1338,6 +1347,7 @@
    
    if (!prjlist_attr_list_parse_from_string(&lp, alp, buffer,
                                           HOSTATTR_ALLOW_AMBIGUITY)) {
+      lFreeList(&lp);
       return 0;
    }
    
@@ -1364,6 +1374,7 @@
    
    if (!time_attr_list_parse_from_string(&lp, alp, buffer,
                                           HOSTATTR_ALLOW_AMBIGUITY)) {
+      lFreeList(&lp);
       return 0;
    }
    
@@ -1390,6 +1401,7 @@
    
    if (!mem_attr_list_parse_from_string(&lp, alp, buffer,
                                           HOSTATTR_ALLOW_AMBIGUITY)) {
+      lFreeList(&lp);
       return 0;
    }
    
diff --exclude-from=/srv/pbuilder/result/sid/sge_ignore -Naur gridengine-6.2~beta2/source/libs/spool/flatfile/sge_spooling_flatfile_scanner.l gridengine-6.2/source/libs/spool/flatfile/sge_spooling_flatfile_scanner.l
--- gridengine-6.2~beta2/source/libs/spool/flatfile/sge_spooling_flatfile_scanner.l	2008-06-15 15:30:01.000000000 +0100
+++ gridengine-6.2/source/libs/spool/flatfile/sge_spooling_flatfile_scanner.l	2008-08-08 18:14:34.000000000 +0100
@@ -44,6 +44,7 @@
 #include <string.h>
 #include <math.h>
 #include <ctype.h>
+#include <unistd.h>
 
 #include "spool/flatfile/sge_spooling_flatfile_scanner.h"
 #include "basis_types.h"
@@ -201,13 +202,20 @@
 
 ^[ \t\r]*{NL}   spool_line++; break;      /* Ignore blank lines */
 
- /* Ignore newlines preceeded by \ */
-[\\][ \t\r]*{NL} {
+ /* Remove line breaks */
+[ \t\r]*[\\][ \t\r]*{NL}[ \t\r]* {
    unput(' ');
    spool_line++;
    break;
 }
 
+[,][ \t\r]*[\\][ \t\r]*{NL}[ \t\r]* {
+   unput(',');
+   spool_line++;
+   break;
+}
+
+
  /* In order to make sure that whitespace before the newline gets removed, we
   * need these two rules.  Just using unput() doesn't work because it could
   * change the token order. */
diff --exclude-from=/srv/pbuilder/result/sid/sge_ignore -Naur gridengine-6.2~beta2/source/libs/uti/config_file.c gridengine-6.2/source/libs/uti/config_file.c
--- gridengine-6.2~beta2/source/libs/uti/config_file.c	2008-06-15 15:29:55.000000000 +0100
+++ gridengine-6.2/source/libs/uti/config_file.c	2008-08-08 18:14:28.000000000 +0100
@@ -274,28 +274,25 @@
  * Parameters:
  *   name:  Name of the config entry
  *   value: Value of the config entry
- *
- * Return Value:
- *   - NULL if a new config value was created or an error occured.
- *   - The old value of the config entry if it already existed.
  *****************************************************************************/
-char* set_conf_val(const char* name, const char* value)
+void set_conf_val(const char* name, const char* value)
 {
    config_entry* pConfigEntry;
-   char* szOldValue=NULL;
 
-   if (!name || !value) {
-      return NULL;
+   if (name == NULL || value == NULL) {
+      return;
    }
    
    pConfigEntry = find_conf_entry(name, config_list);
-   if (pConfigEntry) {
-      szOldValue = pConfigEntry->value;
-      pConfigEntry->value = strdup( value );
+   if (pConfigEntry != NULL) {
+      /* avoid overwriting by itself */
+      if (pConfigEntry->value != value) {
+         FREE(pConfigEntry->value);
+         pConfigEntry->value = strdup(value);
+      }
    } else {
       add_config_entry(name, value);
    }
-   return szOldValue;
 }
 
 /***************************************************/
@@ -303,26 +300,27 @@
    config_entry *ptr = config_list;
    
    ptr = find_conf_entry(name, config_list);
-   if (ptr)
+   if (ptr != NULL) {
       return ptr->value;
-   else
+   } else {
       return NULL;
+   }
 }
 
 /**************************************************
    return NULL if conf value does not exist or
    if "none" is it's value
 */
-char *search_nonone_conf_val(
-const char *name 
-) {
+char *search_nonone_conf_val(const char *name)
+{
    char *s;
 
    s = search_conf_val(name);
-   if (s && !strcasecmp("none", s))
+   if (s != NULL && strcasecmp("none", s) == 0) {
       return NULL;
-   else 
+   } else {
       return s;
+   }
 }
 
 /**************************************************/
diff --exclude-from=/srv/pbuilder/result/sid/sge_ignore -Naur gridengine-6.2~beta2/source/libs/uti/config_file.h gridengine-6.2/source/libs/uti/config_file.h
--- gridengine-6.2~beta2/source/libs/uti/config_file.h	2008-06-15 15:29:55.000000000 +0100
+++ gridengine-6.2/source/libs/uti/config_file.h	2008-08-08 18:14:28.000000000 +0100
@@ -46,7 +46,7 @@
 int replace_params(const char *src, char *dst, int dst_len, char **alllowed);
 void delete_config(void);
 int add_config_entry(const char *name, const char *value);
-char* set_conf_val( const char* name, const char* value );
+void set_conf_val(const char* name, const char* value);
 
 bool parse_bool_param(const char *string, const char *variable, bool *value);
 bool parse_int_param(const char *input, const char *variable, 
diff --exclude-from=/srv/pbuilder/result/sid/sge_ignore -Naur gridengine-6.2~beta2/source/libs/uti/msg_utilib.h gridengine-6.2/source/libs/uti/msg_utilib.h
--- gridengine-6.2~beta2/source/libs/uti/msg_utilib.h	2008-06-15 15:29:55.000000000 +0100
+++ gridengine-6.2/source/libs/uti/msg_utilib.h	2008-08-08 18:14:28.000000000 +0100
@@ -202,6 +202,7 @@
  */
 #define MSG_UTI_CANNOTRESOLVEBOOTSTRAPFILE     _MESSAGE(49100, _("cannot resolve name of bootstrap file"))
 #define MSG_UTI_CANNOTLOCATEATTRIBUTE_SS       _MESSAGE(49102, _("cannot read attribute <"SFN"> from bootstrap file "SFN))
+#define MSG_UTI_CANNOTLOCATEATTRIBUTEMAN_SS    _MESSAGE(49103, _("cannot read attribute <"SFN"> from management.properties file "SFN))
 
 /* 
 ** libs/uti/setup_path.c
diff --exclude-from=/srv/pbuilder/result/sid/sge_ignore -Naur gridengine-6.2~beta2/source/libs/uti/sge_signal.c gridengine-6.2/source/libs/uti/sge_signal.c
--- gridengine-6.2~beta2/source/libs/uti/sge_signal.c	2008-06-15 15:29:55.000000000 +0100
+++ gridengine-6.2/source/libs/uti/sge_signal.c	2008-08-08 18:14:28.000000000 +0100
@@ -424,4 +424,36 @@
    sigprocmask(SIG_SETMASK, &sigmask, NULL);
 }
 
+/****** uti/signal/sge_thread_block_all_signals() *****************************
+*  NAME
+*     sge_thread_block_all_signals()
+*
+*  SYNOPSIS
+*     int sge_thread_block_all_signals(void)
+*
+*  FUNCTION
+*     Blocks all signals the OS knows for the calling thread.
+*
+*  OUTPUTS
+*    sigset_t *oldsigmask - the sigmask of this thread that was set before
+*                           this function was called.
+*
+*  RETURN VALUES
+*     int - 0 if ok,
+*           errno if pthread_sigmask failed,
+*           1000 if oldsigmask == NULL.
+*
+*  NOTES
+*     MT-NOTE: sge_thread_block_signals() is MT safe
+*******************************************************************************/
+int sge_thread_block_all_signals(sigset_t *oldsigmask)
+{
+   sigset_t new_mask;
+   int      ret = 1000;
 
+   if (oldsigmask != NULL) {
+      sigfillset(&new_mask);
+      ret = pthread_sigmask(SIG_BLOCK, &new_mask, oldsigmask);
+   }
+   return ret;
+}
diff --exclude-from=/srv/pbuilder/result/sid/sge_ignore -Naur gridengine-6.2~beta2/source/libs/uti/sge_signal.h gridengine-6.2/source/libs/uti/sge_signal.h
--- gridengine-6.2~beta2/source/libs/uti/sge_signal.h	2008-06-15 15:29:55.000000000 +0100
+++ gridengine-6.2/source/libs/uti/sge_signal.h	2008-08-08 18:14:28.000000000 +0100
@@ -96,6 +96,7 @@
 void sge_set_def_sig_mask(sigset_t*, err_func_t);
 void sge_unblock_all_signals(void);
 
+int sge_thread_block_all_signals(sigset_t *oldsigmask);
 
 #endif /* __SGE_SIGNAL_H */
 
diff --exclude-from=/srv/pbuilder/result/sid/sge_ignore -Naur gridengine-6.2~beta2/source/libs/uti/sge_spool.c gridengine-6.2/source/libs/uti/sge_spool.c
--- gridengine-6.2~beta2/source/libs/uti/sge_spool.c	2008-06-15 15:29:55.000000000 +0100
+++ gridengine-6.2/source/libs/uti/sge_spool.c	2008-08-08 18:14:27.000000000 +0100
@@ -45,6 +45,7 @@
 #include "sge_spool.h"
 #include "sge_stdio.h" 
 #include "sge_unistd.h"
+#include "sge_string.h"
 #include "msg_utilib.h"
 
 #define MAX_JA_TASKS_PER_DIR  (4096l)
@@ -864,3 +865,106 @@
 {
    return silent_flag;
 } 
+
+/****** uti/spool/sge_get_management_entry() *************************************
+*  NAME
+*     sge_get_management_entry() - Read management.properties file entries
+*
+*  SYNOPSIS
+*     int sge_get_management_entry(const char *fname, int n, 
+*                               const char *name[], 
+*                               char value[][1025],
+*                               dstring *error_dstring) 
+*
+*  FUNCTION
+*     Reads in an array of configuration file entries
+*
+*  RESULT
+*     int - 0 on success
+*
+*  BUGS
+*     Function can not differ multiple similar named entries.
+*
+*  NOTES
+*     MT-NOTE: sge_get_management_entry() is MT safe
+******************************************************************************/
+int sge_get_management_entry(const char *fname, int n, int nmissing, bootstrap_entry_t name[], 
+                          char value[][SGE_PATH_MAX], dstring *error_dstring) 
+{
+   FILE *fp;
+   char buf[SGE_PATH_MAX], *cp;
+   int i;
+   bool *is_found = NULL;
+   
+   DENTER(TOP_LAYER, "sge_get_management_entry");
+
+   if (!(fp = fopen(fname, "r"))) {
+      if (error_dstring == NULL){
+         CRITICAL((SGE_EVENT, MSG_FILE_FOPENFAILED_SS, fname, strerror(errno)));
+      }
+      else {
+         sge_dstring_sprintf(error_dstring, MSG_FILE_FOPENFAILED_SS, 
+                             fname, strerror(errno));
+      }
+      DEXIT;
+      return n;
+   }
+   is_found = malloc(sizeof(bool) * n);
+   memset(is_found, false, n * sizeof(bool));
+   
+   while (fgets(buf, sizeof(buf), fp)) {
+      char *pos = NULL;
+
+      /* set chrptr to the first non blank character
+       * If line is empty continue with next line
+       */
+      if(!(cp = strtok_r(buf, " \t\n", &pos))) {
+          continue;
+      }    
+
+      /* allow commentaries */
+      if (cp[0] == '#') {
+          continue;
+      }    
+  
+      /* search for all requested configuration values */ 
+      for (i=0; i<n; i++) {
+         char *nam = strtok_r(cp, "=", &pos);
+         char *val = strtok_r(NULL, "\n", &pos);
+         if (nam != NULL && val != NULL && strcasecmp(name[i].name, nam) == 0) {
+                DPRINTF(("nam = %s\n", nam));
+                DPRINTF(("val = %s\n", val));
+                sge_strlcpy(value[i], val, SGE_PATH_MAX);
+                is_found[i] = true;
+                if (name[i].is_required) {
+                  --nmissing; 
+                }
+                break;
+         }
+      }
+   }
+   if (nmissing != 0) {
+      for (i=0; i<n; i++) {
+         if (!is_found[i] && name[i].is_required) {
+            if (error_dstring == NULL){
+               CRITICAL((SGE_EVENT, MSG_UTI_CANNOTLOCATEATTRIBUTEMAN_SS, name[i].name, fname));
+            }
+            else {
+               sge_dstring_sprintf(error_dstring, MSG_UTI_CANNOTLOCATEATTRIBUTEMAN_SS, 
+                                   name[i].name, fname);
+            }
+            
+            break;
+         }
+      }
+   }
+   
+   FREE(is_found);
+   FCLOSE(fp);
+   DEXIT;
+   return nmissing;
+FCLOSE_ERROR:
+   DEXIT;
+   return 0;
+} /* sge_get_management_entry() */
+
diff --exclude-from=/srv/pbuilder/result/sid/sge_ignore -Naur gridengine-6.2~beta2/source/libs/uti/sge_spool.h gridengine-6.2/source/libs/uti/sge_spool.h
--- gridengine-6.2~beta2/source/libs/uti/sge_spool.h	2008-06-15 15:29:55.000000000 +0100
+++ gridengine-6.2/source/libs/uti/sge_spool.h	2008-08-08 18:14:28.000000000 +0100
@@ -243,4 +243,7 @@
 
 int sge_silent_get(void); 
 
+int sge_get_management_entry(const char *fname, int n, int nmissing, bootstrap_entry_t name[],
+                          char value[][SGE_PATH_MAX], dstring *error_dstring);
+
 #endif /* _SGE_FILE_PATH_H_ */
diff --exclude-from=/srv/pbuilder/result/sid/sge_ignore -Naur gridengine-6.2~beta2/source/libs/uti/sge_string.c gridengine-6.2/source/libs/uti/sge_string.c
--- gridengine-6.2~beta2/source/libs/uti/sge_string.c	2008-06-15 15:29:55.000000000 +0100
+++ gridengine-6.2/source/libs/uti/sge_string.c	2008-08-08 18:14:28.000000000 +0100
@@ -1382,13 +1382,16 @@
 
    DENTER(BASIS_LAYER, "string_list");
 
-   if (!str) {
+   if (str == NULL) {
       DRETURN(NULL);
    }
 
-   while (strchr(delis, str[0])) {
+   /* skip heading delimiters */
+   while (str[0] != '\0' && strchr(delis, str[0]) != NULL) {
       str++;
    }
+
+   /* at str end: str either was an empty string or only contained delimiters */
    if (str[0] == '\0') {
       DRETURN(NULL);
    }
@@ -1396,13 +1399,12 @@
    /*
     * not more items than length of string is possible
     */
-   if (!pstr) {
+   if (pstr == NULL) {
       head = malloc((sizeof(void *)) * (strlen(str) + 1));
-      if (!head) {
+      if (head == NULL) {
          DRETURN(NULL);
       }
-   }
-   else {
+   } else {
       head = pstr;
    }
 
@@ -1427,8 +1429,7 @@
       while ((str[i] != '\0') && !is_space) {
          if ((found_first_quote == 0) && (str[i] == '"')) {
             found_first_quote = 2;
-         }
-         else if ((found_first_quote == 0) && (str[i] == '\'')) {
+         } else if ((found_first_quote == 0) && (str[i] == '\'')) {
             found_first_quote = 1;
          }
 

Attachment: signature.asc
Description: Digital signature


Reply to: