Changeset 1633


Ignore:
Timestamp:
Nov 15, 2004, 9:21:54 AM (21 years ago)
Author:
bird
Message:

Bugfixing.

Location:
trunk/src/emx
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/emx/include/signal.h

    • Property cvs2svn:cvs-rev changed from 1.5 to 1.6
    r1632 r1633  
    33 * @changed bird:   Added sighold(), sigignore(), sigrelse(). Added wrapper
    44 *                  between the two sigpause() APIs.
     5 * @changed bird:   include sys/timespec.h.
    56 */
    67
     
    4748#include <sys/_types.h>
    4849#include <sys/signal.h>
     50#include <sys/timespec.h>               /* bird: Need full timespec declaration. */
    4951
    5052#if __BSD_VISIBLE
  • trunk/src/emx/src/lib/process/sigtimedwait.c

    • Property cvs2svn:cvs-rev changed from 1.2 to 1.3
    r1632 r1633  
    6565    siginfo_t SigInfo;
    6666    int rc = __libc_Back_signalWait(pSigSet, &SigInfo, pTimeout);
    67     if (!rc)
     67    if (rc >= 0)
    6868    {
    6969        if (pSigInfo)
  • trunk/src/emx/src/lib/process/sigwait.c

    • Property cvs2svn:cvs-rev changed from 1.2 to 1.3
    r1632 r1633  
    6060    if (piSignalNo)
    6161        *piSignalNo = SigInfo.si_signo;
     62    if (rc > 0)
     63        rc = 0;
    6264
    6365    LIBCLOG_RETURN_MSG(rc, "ret rc (*piSignalNo=%d)\n", SigInfo.si_signo);
  • trunk/src/emx/src/lib/sys/b_signalSuspend.c

    • Property cvs2svn:cvs-rev changed from 1.5 to 1.6
    r1632 r1633  
    7676     */
    7777    rc = __libc_back_signalWait(pThrd, &SigSuspend.fDone, NULL);
    78     if (rc != EAGAIN)
    79         __libc_back_signalSemRelease();
     78    __libc_back_signalSemRelease();
    8079    LIBCLOG_RETURN_INT(rc);
    8180}
  • trunk/src/emx/src/lib/sys/b_signalWait.c

    • Property cvs2svn:cvs-rev changed from 1.3 to 1.4
    r1632 r1633  
    100100        sigset_t    SigSetPending;
    101101        __SIGSET_OR(&SigSetPending, &pThrd->SigSetPending, &__libc_gSignalPending);
    102         __SIGSET_AND(&SigSetPending, &pThrd->SigSetPending, &SigSet);
     102        __SIGSET_AND(&SigSetPending, &SigSetPending, &SigSet);
    103103        if (!__SIGSET_ISEMPTY(&SigSetPending))
    104104        {
     
    133133     * Wait till state changes back and then return according to the wait result.
    134134     *
    135      * The result is a bit tricky. EAGAIN means time out and no semaphore. While
    136      * EINTR means that we've been interrupted by the delivery of a signal, which
    137      * might mean that we got what we waited for or that some other signal was
    138      * delivered to this thread. Very simple. :-)
     135     * EAGAIN means time out. While EINTR means that we've been interrupted by
     136     * the delivery of a signal, which might mean that we got what we waited
     137     * for or that some other signal was delivered to this thread. Very simple. :-)
    139138     */
    140139    rc = __libc_back_signalWait(pThrd, &SigWait.fDone, pTimeout ? &Timeout : NULL);
    141     if (rc != -EAGAIN)
    142         __libc_back_signalSemRelease();
     140    pThrd->enmStatus = enmLIBCThreadStatus_unknown;
     141    __libc_back_signalSemRelease();
    143142    if (rc == -EINTR)
    144143    {
     
    151150    }
    152151
     152
    153153    LIBCLOG_RETURN_MSG(rc, "ret %d SigWait.SigInfo={si_signo=%d, si_errno=%d, si_code=%#x, si_timestamp=%#x, si_flags=%#x, si_pid=%d, si_tid=%d, si_uid=%d, si_status=%d, si_addr=%p, si_value=%#08x, si_band=%ld}\n",
    154154                       rc, SigWait.SigInfo.si_signo, SigWait.SigInfo.si_errno, SigWait.SigInfo.si_code, SigWait.SigInfo.si_timestamp,
  • trunk/src/emx/src/lib/sys/sharedpm.c

    • Property cvs2svn:cvs-rev changed from 1.22 to 1.23
    r1632 r1633  
    804804     */
    805805    int rc = spmRequestMutex(&RegRec);
    806     if (!rc)
     806    if (rc)
    807807        LIBCLOG_RETURN_INT(rc);
    808808
     
    851851     */
    852852    int rc = spmRequestMutex(&RegRec);
    853     if (!rc)
     853    if (rc)
    854854        LIBCLOG_RETURN_INT(rc);
    855855
     
    895895     */
    896896    int rc = spmRequestMutex(&RegRec);
    897     if (!rc)
     897    if (rc)
    898898        LIBCLOG_RETURN_INT(rc);
    899899
     
    943943     */
    944944    int rc = spmRequestMutex(&RegRec);
    945     if (!rc)
     945    if (rc)
    946946        LIBCLOG_RETURN_INT(rc);
    947947
     
    10071007    if (!rc)
    10081008        LIBCLOG_RETURN_INT(0);
    1009     errno = rc;
     1009    errno = -rc;
    10101010    LIBCLOG_RETURN_INT(-1);
    10111011}
     
    14131413    for (; pProcess; pProcess = pProcess->pNext)
    14141414    {
    1415         if (    pProcess->pgrp != pgrp
    1416             && !pProcess->fExeInited)
     1415        if (    pProcess->pgrp == pgrp
     1416            &&  pProcess->fExeInited)
    14171417        {
    14181418            /* try queue the signal */
  • trunk/src/emx/src/lib/sys/signals.c

    • Property cvs2svn:cvs-rev changed from 1.12 to 1.13
    r1632 r1633  
    17611761                 )
    17621762        {
    1763             pThrd->u.pSigSuspend->fDone = 1;
    1764             pThrd->u.pSigSuspend = NULL;
    1765             pThrd->enmStatus = enmLIBCThreadStatus_sigsuspend;
     1763            if (pThrd->u.pSigSuspend)
     1764            {
     1765                pThrd->u.pSigSuspend->fDone = 1;
     1766                pThrd->u.pSigSuspend = NULL;
     1767            }
     1768            pThrd->enmStatus = enmLIBCThreadStatus_unknown;
    17661769        }
    17671770
     
    19411944            /*
    19421945             * Re-take the signal semaphore and restore the signal mask.
     1946             * We'll have to reschedule signals here unless the two masks are 100% equal
    19431947             */
    19441948            if (__libc_back_signalSemRequest())
    19451949                break;
    19461950            pThrd->SigSetBlocked = SigSetOld;
     1951            signalScheduleSPM(pThrd);
     1952            signalScheduleProcess(pThrd);
    19471953        }
    19481954
     
    21342140     * Wait for interruption (outside semaphores of course).
    21352141     */
     2142    DosSleep(0);                        /** @todo rewrite to call the signalWait worker and change the thread state while here! */
    21362143    __libc_back_signalSemRelease();
    2137     DosWaitEventSem(__libc_back_ghevWait, SEM_INDEFINITE_WAIT);
     2144    int rc;
     2145    do rc = DosWaitEventSem(__libc_back_ghevWait, 24*3600*1000); while (rc == ERROR_SEM_TIMEOUT || rc == ERROR_TIMEOUT);
    21382146    return __libc_back_signalSemRequest();
    21392147}
     
    22222230        /*
    22232231         * Check that the process exists first.
    2224          */
     2232         * Only root users are allowed to do this. (Mainly to fix some testcases :-)
     2233         */
     2234        if (__libc_spmGetId(__LIBC_SPMID_EUID))
     2235            LIBCLOG_RETURN_MSG(-EPERM, "%d (Only root can signal OS/2 processes.) euid=%d\n", -EPERM, __libc_spmGetId(__LIBC_SPMID_EUID));
    22252236        FS_SAVE_LOAD();
    22262237        rc = DosVerifyPidTid(pid, 1);
     
    23732384    if (SigInfo.si_pid)
    23742385        SigInfo.si_pid      = _sys_pid;
    2375     __LIBC_PTHREAD pThrd    = __libc_threadCurrentNoAuto();
     2386    __LIBC_PTHREAD pThrd    = __libc_threadCurrent();
    23762387    if (pThrd)
    23772388        SigInfo.si_tid      = pThrd->tid;
     
    23922403     */
    23932404    rc = __libc_spmSigQueuePGrp(iSignalNo, &SigInfo, pgrp, SigInfo.si_flags & __LIBC_SI_QUEUED, signalSendPGrpCallback, NULL);
     2405
     2406    /*
     2407     * Just in case the signal were for our selves too, we'll do the
     2408     * schedule & deliver stuff.
     2409     */
     2410    signalScheduleSPM(pThrd);
     2411    signalScheduleProcess(pThrd);
     2412    signalDeliver(pThrd, 0, NULL);
    23942413
    23952414    __libc_back_signalSemRelease();
     
    29472966                bzero(pSigInfo, sizeof(*pSigInfo));
    29482967                pSigInfo->si_signo = iSignalNo;
     2968                pSigInfo->si_code = SI_USER;
    29492969            }
    29502970        }
     
    29732993     * Calc wait period.
    29742994     */
    2975     ULONG cMillies = SEM_INDEFINITE_WAIT;
     2995    ULONG cMillies = 30*1000;
    29762996    if (pTimeout)
    29772997    {
    2978         cMillies = pTimeout->tv_nsec * 1000 + pTimeout->tv_sec / 1000;
    2979         if (!cMillies && pTimeout->tv_sec)
     2998        if (pTimeout->tv_nsec >= 100000000 || pTimeout->tv_nsec < 0)
     2999        {
     3000            LIBC_ASSERTM_FAILED("Invalid tv_nsec! tv_sec=%d tv_nsec=%ld\n", pTimeout->tv_sec, pTimeout->tv_nsec);
     3001            LIBCLOG_RETURN_INT(-EINVAL);
     3002        }
     3003        if (    pTimeout->tv_sec < 0
     3004            ||  pTimeout->tv_sec >= 4294967)
     3005        {
     3006            LIBC_ASSERTM_FAILED("Invalid tv_sec! tv_sec=%d (max=4294967) tv_nsec=%ld\n", pTimeout->tv_sec, pTimeout->tv_nsec);
     3007            LIBCLOG_RETURN_INT(-EINVAL);
     3008        }
     3009
     3010        cMillies = pTimeout->tv_sec * 1000 + pTimeout->tv_nsec / 1000000;
     3011        if (!cMillies && pTimeout->tv_nsec)
    29803012            cMillies = 1;
    29813013    }
    29823014
    29833015    /*
    2984      * Wait for interruption (outside semaphores of course).
    2985      */
     3016     * Wait for interruption.
     3017     */
     3018    int rc = 0;
    29863019    FS_VAR();
    29873020    FS_SAVE_LOAD();
    29883021    ULONG ulStart = 0;
    29893022    DosQuerySysInfo(QSV_MS_COUNT, QSV_MS_COUNT, &ulStart, sizeof(ulStart));
    2990     __libc_back_signalSemRelease();
    29913023    for (;;)
    29923024    {
    2993         int rc = DosWaitEventSem(__libc_back_ghevWait, cMillies);
     3025        /*
     3026         * Release the semaphore and recheck exit condition before
     3027         * engaging in waiting again.
     3028         */
     3029        DosSleep(0);                    /** @todo need better methods for waiting! */
     3030        __libc_back_signalSemRelease();
     3031        if (*pfDone)
     3032        {
     3033            rc = -EINTR;
     3034            break;
     3035        }
     3036        rc = DosWaitEventSem(__libc_back_ghevWait, cMillies);
    29943037
    29953038        /*
    29963039         * We returned from the wait, but did we do so for the right reason?
    29973040         */
    2998         if (rc == ERROR_TIMEOUT || rc == ERROR_SEM_TIMEOUT)
    2999         {
    3000             FS_RESTORE();
    3001             LIBCLOG_RETURN_INT(-EAGAIN);
    3002         }
    3003         rc = __libc_back_signalSemRequest();
    3004         if (*pfDone)
    3005         {
    3006             FS_RESTORE();
    3007             LIBCLOG_RETURN_INT(-EINTR);
    3008         }
     3041        if (__libc_back_signalSemRequest())
     3042            rc = -EDEADLK;
     3043        else if (*pfDone)
     3044            rc = -EINTR;
     3045        else if (pTimeout && (rc == ERROR_TIMEOUT || rc == ERROR_SEM_TIMEOUT))
     3046            rc = -EAGAIN;
     3047        if (rc < 0)
     3048            break;
    30093049
    30103050        /*
    30113051         * Resume waiting.
    30123052         */
    3013         if (cMillies != SEM_INDEFINITE_WAIT)
     3053        if (pTimeout)
    30143054        {
    30153055            ULONG ulEnd = 0;
     
    30233063        }
    30243064    } /* for ever */
     3065
     3066    FS_RESTORE();
     3067    LIBCLOG_RETURN_INT(rc);
    30253068}
    30263069
Note: See TracChangeset for help on using the changeset viewer.