bool_t cldmgr_create( int ( * entry )( void *arg1 ), u_intgen_t inh, ix_t streamix, char *descstr, void *arg1 ) { cld_t *cldp; pid_t cldpid; ASSERT( getpid( ) == cldmgr_parentpid ); cldp = cldmgr_getcld( ); if ( ! cldp ) { mlog( MLOG_NORMAL | MLOG_ERROR | MLOG_PROC, _( "cannot create %s thread for stream %u: " "too many child threads (max allowed is %d)\n"), descstr, streamix, CLD_MAX ); return BOOL_FALSE; } cldp->c_streamix = streamix; cldp->c_entry = entry; cldp->c_arg1 = arg1; cldpid = ( pid_t )sproc( cldmgr_entry, inh, ( void * )cldp ); if ( cldpid < 0 ) { mlog( MLOG_NORMAL | MLOG_ERROR | MLOG_PROC, _( "sproc failed creating %s thread for stream %u: %s\n"), descstr, streamix, strerror( errno )); } else { mlog( MLOG_NITTY | MLOG_PROC, "%s thread created for stream %u: pid %d\n", descstr, streamix, cldpid ); } return cldpid < 0 ? BOOL_FALSE : BOOL_TRUE; }
bool_t cldmgr_create( int ( * entry )( void *arg1 ), ix_t streamix, char *descstr, void *arg1 ) { cld_t *cldp; intgen_t rval; ASSERT( pthread_equal( pthread_self( ), cldmgr_parenttid ) ); cldp = cldmgr_getcld( ); if ( ! cldp ) { mlog( MLOG_NORMAL | MLOG_ERROR | MLOG_PROC, _( "cannot create %s thread for stream %u: " "too many child threads (max allowed is %d)\n"), descstr, streamix, CLD_MAX ); return BOOL_FALSE; } cldp->c_exit_code = EXIT_INTERRUPT; cldp->c_streamix = streamix; cldp->c_entry = entry; cldp->c_arg1 = arg1; rval = pthread_create( &cldp->c_tid, NULL, cldmgr_entry, cldp ); if ( rval ) { mlog( MLOG_NORMAL | MLOG_ERROR | MLOG_PROC, _( "failed creating %s thread for stream %u: %s\n"), descstr, streamix, strerror( rval )); } else { mlog( MLOG_NITTY | MLOG_PROC, "%s thread created for stream %u: tid %lu\n", descstr, streamix, cldp->c_tid ); } return rval ? BOOL_FALSE : BOOL_TRUE; }