Print this page
10141 smatch fix for zoneadmd


2257          * This is the next-to-last part of the exit interlock.  Upon calling
2258          * fdetach(), the door will go unreferenced; once any
2259          * outstanding requests (like the door thread doing Z_HALT) are
2260          * done, the door will get an UNREF notification; when it handles
2261          * the UNREF, the door server will cause the exit.  It's possible
2262          * that fdetach() can fail because the file is in use, in which
2263          * case we'll retry the operation.
2264          */
2265         assert(!MUTEX_HELD(&lock));
2266         for (;;) {
2267                 if ((fdetach(zone_door_path) == 0) || (errno != EBUSY))
2268                         break;
2269                 yield();
2270         }
2271 
2272         for (;;)
2273                 (void) pause();
2274 
2275 child_out:
2276         assert(pid == 0);
2277         if (shstate != NULL) {
2278                 shstate->status = -1;
2279                 (void) sema_post(&shstate->sem);
2280                 (void) munmap((char *)shstate, shstatelen);
2281         }
2282 
2283         /*
2284          * This might trigger an unref notification, but if so,
2285          * we are still holding the lock, so our call to exit will
2286          * ultimately win the race and will publish the right exit
2287          * code.
2288          */
2289         if (zone_door != -1) {
2290                 assert(MUTEX_HELD(&lock));
2291                 (void) door_revoke(zone_door);
2292                 (void) fdetach(zone_door_path);
2293         }
2294 
2295         if (dld_handle != NULL)
2296                 dladm_close(dld_handle);
2297 
2298         return (1); /* return from main() forcibly exits an MT process */
2299 }


2257          * This is the next-to-last part of the exit interlock.  Upon calling
2258          * fdetach(), the door will go unreferenced; once any
2259          * outstanding requests (like the door thread doing Z_HALT) are
2260          * done, the door will get an UNREF notification; when it handles
2261          * the UNREF, the door server will cause the exit.  It's possible
2262          * that fdetach() can fail because the file is in use, in which
2263          * case we'll retry the operation.
2264          */
2265         assert(!MUTEX_HELD(&lock));
2266         for (;;) {
2267                 if ((fdetach(zone_door_path) == 0) || (errno != EBUSY))
2268                         break;
2269                 yield();
2270         }
2271 
2272         for (;;)
2273                 (void) pause();
2274 
2275 child_out:
2276         assert(pid == 0);
2277 
2278         shstate->status = -1;
2279         (void) sema_post(&shstate->sem);
2280         (void) munmap((char *)shstate, shstatelen);

2281 
2282         /*
2283          * This might trigger an unref notification, but if so,
2284          * we are still holding the lock, so our call to exit will
2285          * ultimately win the race and will publish the right exit
2286          * code.
2287          */
2288         if (zone_door != -1) {
2289                 assert(MUTEX_HELD(&lock));
2290                 (void) door_revoke(zone_door);
2291                 (void) fdetach(zone_door_path);
2292         }
2293 
2294         if (dld_handle != NULL)
2295                 dladm_close(dld_handle);
2296 
2297         return (1); /* return from main() forcibly exits an MT process */
2298 }