Changeset 398 for trunk/src


Ignore:
Timestamp:
Mar 27, 2012, 9:57:35 PM (13 years ago)
Author:
katerina
Message:

Fix for ticket #295 (Deadlock if sh_processes_readps hangs).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/sh_processcheck.c

    r394 r398  
    864864{
    865865  int  cc;
    866   unsigned int  lnum   = 0;
    867   unsigned long num    = 0;
     866  volatile unsigned int  lnum   = 0;
     867  volatile unsigned long num    = 0;
    868868  char c;
    869869  unsigned int  pos = 0;
     
    907907              char errbuf[SH_ERRBUF_SIZE];
    908908
    909               /* SH_MUTEX_LOCK(mutex_thread_nolog) is in caller */
     909              SH_MUTEX_LOCK(mutex_thread_nolog);
    910910              sh_error_handle(SH_ERR_ALL, FIL__, __LINE__, errno, MSG_E_SUBGEN,
    911911                              sh_error_message(errno, errbuf, sizeof(errbuf)),
    912912                              _("sh_processes_readps"));
     913              SH_MUTEX_UNLOCK(mutex_thread_nolog);
    913914              break;
    914915            }
     
    930931              if (flag_err_debug == SL_TRUE)
    931932                {
    932                   /* SH_MUTEX_LOCK(mutex_thread_nolog) is in caller */
     933                  SH_MUTEX_LOCK(mutex_thread_nolog);
    933934                  sh_error_handle(SH_ERR_ALL, FIL__, __LINE__, num,
    934935                                  MSG_E_SUBGEN,
    935936                                  tstr,
    936937                                  _("sh_processes_readps"));
     938                  SH_MUTEX_UNLOCK(mutex_thread_nolog);
    937939                }
    938940              /* fprintf(stderr, "<%ld> %s\n", num, tstr); */
     
    10781080  if (status != 0)
    10791081    {
    1080       /* SH_MUTEX_LOCK(mutex_thread_nolog) is in caller */
     1082      SH_MUTEX_LOCK(mutex_thread_nolog);
    10811083      sh_error_handle(SH_ERR_ALL, FIL__, __LINE__, status, MSG_E_SUBGEN,
    10821084                      _("Could not open pipe"), _("sh_processes_runps"));
     1085      SH_MUTEX_UNLOCK(mutex_thread_nolog);
    10831086      SL_RETURN ((-1), _("sh_processes_runps"));
    10841087    }
     
    11611164    }
    11621165
    1163   SH_MUTEX_LOCK(mutex_thread_nolog);
    11641166  retval = sh_processes_runps (res, NULL, 0, SH_PR_PS, 0);
    1165   SH_MUTEX_UNLOCK(mutex_thread_nolog);
     1167
    11661168  for (i = sh_prochk_minpid; i != sh_prochk_maxpid; ++i)
    11671169    {
     
    11691171      res[j] = sh_processes_check ((pid_t) i, res[j]);
    11701172    }
    1171   SH_MUTEX_LOCK(mutex_thread_nolog);
     1173
    11721174  retval += sh_processes_runps (res, NULL, 0, SH_PR_PS2, 0);
    1173   SH_MUTEX_UNLOCK(mutex_thread_nolog);
    11741175
    11751176  if (retval != 0)
Note: See TracChangeset for help on using the changeset viewer.