Projects
Browse Source     Search     Timeline     Wiki

Changeset 23333

Show
Ignore:
Timestamp:
08/14/07 09:06:10 (16 months ago)
Author:
zarzycki@…
Message:

<rdar://problem/5321044> Bug: launchd_core_logic.c:3012 (23294):2: kevent_mod(si->fd, EVFILT_VNODE, EV_ADD, fflags, 0, j) != -1

Location:
trunk/launchd/src
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/launchd/src/launchd_core_logic.c

    r23330 r23333  
    30453045        } 
    30463046 
    3047         if (si->fd == -1) { 
    3048                 if ((si->fd = _fd(open(which_path, O_EVTONLY|O_NOCTTY))) == -1) { 
    3049                         which_path = parentdir_path; 
    3050                         si->fd = _fd(open(which_path, O_EVTONLY|O_NOCTTY)); 
    3051                 } 
    3052         } 
    3053  
    3054         if (si->fd == -1) { 
    3055                 return job_log_error(j, LOG_ERR, "Watchpath monitoring failed on \"%s\"", which_path); 
    3056         } 
    3057  
    3058         job_log(j, LOG_DEBUG, "Watching Vnode: %d", si->fd); 
    3059         if (!job_assumes(j, kevent_mod(si->fd, EVFILT_VNODE, EV_ADD, fflags, 0, j) != -1)) { 
    3060                 /* Extra logging for 5321044 */ 
    3061                 job_log(j, LOG_ERR, "Bug (5321044): si->why == %u si->fd == %d fflags = 0x%x j == %p", si->why, si->fd, fflags, j); 
    3062         } 
     3047        do { 
     3048                if (si->fd == -1) { 
     3049                        if ((si->fd = _fd(open(which_path, O_EVTONLY|O_NOCTTY))) == -1) { 
     3050                                which_path = parentdir_path; 
     3051                                si->fd = _fd(open(which_path, O_EVTONLY|O_NOCTTY)); 
     3052                        } 
     3053                } 
     3054 
     3055                if (si->fd == -1) { 
     3056                        return job_log_error(j, LOG_ERR, "Watchpath monitoring failed on \"%s\"", which_path); 
     3057                } 
     3058 
     3059                job_log(j, LOG_DEBUG, "Watching Vnode: %d", si->fd); 
     3060 
     3061                if (kevent_mod(si->fd, EVFILT_VNODE, EV_ADD, fflags, 0, j) == -1) { 
     3062                        /* 
     3063                         * The FD can be revoked between the open() and kevent(). 
     3064                         * This is similar to the inability for kevents to be 
     3065                         * attached to short lived zombie processes after fork() 
     3066                         * but before kevent(). 
     3067                         */ 
     3068                        job_assumes(j, runtime_close(si->fd) == 0); 
     3069                        si->fd = -1; 
     3070                } 
     3071        } while (si->fd == -1); 
    30633072} 
    30643073 
  • trunk/launchd/src/launchd_runtime.c

    r23332 r23333  
    721721        r = kevent(mainkq, &kev, 1, &kev, 1, NULL); 
    722722 
    723 #define BUG_5321044_RESEARCH 1 
    724 #if BUG_5321044_RESEARCH 
    725         if (r != 1) { 
    726                 runtime_syslog(LOG_ERR, "Bug (5321044): kevent_mod() == %d", r); 
     723        if (!launchd_assumes(r == 1)) { 
    727724                return -1; 
    728725        } 
    729726 
    730727        if (launchd_assumes(kev.flags & EV_ERROR)) { 
    731                 if ((flags & EV_ADD) && kev.data) { 
    732                         runtime_syslog(LOG_ERR, "Bug (5321044): See next line."); 
     728                if ((flags & EV_ADD) && !launchd_assumes(kev.data == 0)) { 
    733729                        log_kevent_struct(LOG_ERR, &kev, 0); 
    734730                        errno = kev.data; 
     
    736732                } 
    737733        } 
    738 #endif 
    739734 
    740735        return r;