Print this page
5218 posix definition of NULL
correct unistd.h and iso/stddef_iso.h
update gate source affected


 327                 else if (strcmp(esc, ESC_DR_REQ) == 0)
 328                         ename = strdup(PICLEVENT_DR_REQ);
 329                 else
 330                         return (0);
 331         } else {
 332                 return (0);
 333         }
 334 
 335         if (ename == NULL)
 336                 return (EAGAIN);
 337 
 338         /*
 339          * Make a copy to expand attribute list
 340          */
 341         dupev = sysevent_dup(ev);
 342         if (dupev == NULL) {
 343                 free(ename);
 344                 return (EAGAIN);
 345         }
 346 
 347         if (nvlist_alloc(&nvl, NV_UNIQUE_NAME_TYPE, NULL)) {
 348                 free(ename);
 349                 sysevent_free(dupev);
 350                 return (EAGAIN);
 351         }
 352 
 353         if (strcmp(ec, EC_DEVFS) == 0) {
 354                 rval = piclslm_add_ec_devfs_args(nvl, dupev);
 355         } else if (strcmp(ec, EC_DR) == 0) {
 356                 if (strcmp(esc, ESC_DR_REQ) == 0) {
 357                         rval = piclslm_add_ec_dr_req_args(nvl, dupev);
 358                 } else {
 359                         rval = piclslm_add_ec_dr_args(nvl, dupev);
 360                 }
 361         }
 362 
 363         if (rval != 0) {
 364                 free(ename);
 365                 nvlist_free(nvl);
 366                 sysevent_free(dupev);
 367                 return ((rval == EAGAIN) ? EAGAIN : 0);
 368         }
 369 
 370         pack_buf = NULL;
 371         if (nvlist_add_string(nvl, PICLEVENTARG_EVENT_NAME, ename) ||
 372             nvlist_add_string(nvl, PICLEVENTARG_DATA_TYPE,
 373             PICLEVENTARG_PICLEVENT_DATA) ||
 374             nvlist_pack(nvl, &pack_buf, &nvl_size, NV_ENCODE_NATIVE, NULL)) {
 375                 free(ename);
 376                 nvlist_free(nvl);
 377                 sysevent_free(dupev);
 378                 return (EAGAIN);
 379         }
 380 
 381         /*
 382          * Add nvlist_t to queue
 383          */
 384         (void) mutex_lock(&nvq_lock);
 385         retval = add_to_queue(pack_buf, nvl_size);
 386         (void) cond_signal(&nvq_cv);
 387         (void) mutex_unlock(&nvq_lock);
 388 
 389         nvlist_free(nvl);
 390         sysevent_free(dupev);
 391         free(ename);
 392         return (retval < 0 ? EAGAIN : 0);
 393 }
 394 
 395 struct slm_mod_ops *
 396 slm_init(void)
 397 {
 398         cleanup = 0;
 399 
 400         init_queue();
 401 
 402         (void) mutex_init(&nvq_lock, USYNC_THREAD, NULL);
 403         (void) cond_init(&nvq_cv, USYNC_THREAD, NULL);
 404 
 405         if (thr_create(NULL, NULL, piclslm_deliver_thr,
 406             NULL, THR_BOUND, &piclslm_deliver_thr_id) != 0) {
 407                 (void) mutex_destroy(&nvq_lock);
 408                 (void) cond_destroy(&nvq_cv);
 409                 return (NULL);
 410         }
 411         return (&piclslm_mod_ops);
 412 }
 413 
 414 void
 415 slm_fini(void)
 416 {
 417         /*
 418          * Wait for all events to be sent
 419          */
 420         (void) mutex_lock(&nvq_lock);
 421         cleanup = 1;
 422         (void) cond_signal(&nvq_cv);
 423         (void) mutex_unlock(&nvq_lock);
 424 
 425         /* Wait for delivery thread to exit */


 327                 else if (strcmp(esc, ESC_DR_REQ) == 0)
 328                         ename = strdup(PICLEVENT_DR_REQ);
 329                 else
 330                         return (0);
 331         } else {
 332                 return (0);
 333         }
 334 
 335         if (ename == NULL)
 336                 return (EAGAIN);
 337 
 338         /*
 339          * Make a copy to expand attribute list
 340          */
 341         dupev = sysevent_dup(ev);
 342         if (dupev == NULL) {
 343                 free(ename);
 344                 return (EAGAIN);
 345         }
 346 
 347         if (nvlist_alloc(&nvl, NV_UNIQUE_NAME_TYPE, 0)) {
 348                 free(ename);
 349                 sysevent_free(dupev);
 350                 return (EAGAIN);
 351         }
 352 
 353         if (strcmp(ec, EC_DEVFS) == 0) {
 354                 rval = piclslm_add_ec_devfs_args(nvl, dupev);
 355         } else if (strcmp(ec, EC_DR) == 0) {
 356                 if (strcmp(esc, ESC_DR_REQ) == 0) {
 357                         rval = piclslm_add_ec_dr_req_args(nvl, dupev);
 358                 } else {
 359                         rval = piclslm_add_ec_dr_args(nvl, dupev);
 360                 }
 361         }
 362 
 363         if (rval != 0) {
 364                 free(ename);
 365                 nvlist_free(nvl);
 366                 sysevent_free(dupev);
 367                 return ((rval == EAGAIN) ? EAGAIN : 0);
 368         }
 369 
 370         pack_buf = NULL;
 371         if (nvlist_add_string(nvl, PICLEVENTARG_EVENT_NAME, ename) ||
 372             nvlist_add_string(nvl, PICLEVENTARG_DATA_TYPE,
 373             PICLEVENTARG_PICLEVENT_DATA) ||
 374             nvlist_pack(nvl, &pack_buf, &nvl_size, NV_ENCODE_NATIVE, 0)) {
 375                 free(ename);
 376                 nvlist_free(nvl);
 377                 sysevent_free(dupev);
 378                 return (EAGAIN);
 379         }
 380 
 381         /*
 382          * Add nvlist_t to queue
 383          */
 384         (void) mutex_lock(&nvq_lock);
 385         retval = add_to_queue(pack_buf, nvl_size);
 386         (void) cond_signal(&nvq_cv);
 387         (void) mutex_unlock(&nvq_lock);
 388 
 389         nvlist_free(nvl);
 390         sysevent_free(dupev);
 391         free(ename);
 392         return (retval < 0 ? EAGAIN : 0);
 393 }
 394 
 395 struct slm_mod_ops *
 396 slm_init(void)
 397 {
 398         cleanup = 0;
 399 
 400         init_queue();
 401 
 402         (void) mutex_init(&nvq_lock, USYNC_THREAD, NULL);
 403         (void) cond_init(&nvq_cv, USYNC_THREAD, NULL);
 404 
 405         if (thr_create(NULL, 0, piclslm_deliver_thr,
 406             NULL, THR_BOUND, &piclslm_deliver_thr_id) != 0) {
 407                 (void) mutex_destroy(&nvq_lock);
 408                 (void) cond_destroy(&nvq_cv);
 409                 return (NULL);
 410         }
 411         return (&piclslm_mod_ops);
 412 }
 413 
 414 void
 415 slm_fini(void)
 416 {
 417         /*
 418          * Wait for all events to be sent
 419          */
 420         (void) mutex_lock(&nvq_lock);
 421         cleanup = 1;
 422         (void) cond_signal(&nvq_cv);
 423         (void) mutex_unlock(&nvq_lock);
 424 
 425         /* Wait for delivery thread to exit */