int main() { TEST_THREAD_DATA threads_data[NUMBER_OF_TEST_THREADS]; THR_HANDLE thread_handle[NUMBER_OF_TEST_THREADS]; unsigned i; int found_error = 0; srand( (unsigned)time( NULL ) ); memset( threads_data, 0, sizeof(threads_data) ); for ( i = 0; i < NUMBER_OF_TEST_THREADS; i++ ) { threads_data[i].index = i; threads_data[i].sleep_interval_millis = get_random_value( MAX_THREAD_SLEEP_MILLIS ); thread_handle[i] = launch_thread( &threads_data[i] ); if ( !thread_handle[i] ) { fprintf( stderr, "failed to launch worker thread, error code is %d\n", LAST_ERROR() ); return EXIT_FAILURE; } } for ( i = 0; i < NUMBER_OF_TEST_THREADS; i++ ) if ( join_thread( thread_handle[i] ) != 0 ) { fprintf( stderr, "failed to join thread %d, error code is %d\n", i, LAST_ERROR() ); return EXIT_FAILURE; } for ( i = 0; i < NUMBER_OF_TEST_THREADS; i++ ) { if( threads_data[i].error_occured ) { fprintf( stderr, "error occured at thread %d: %s\n", i, threads_data[i].error_message ); found_error = 1; } } if ( found_error ) return EXIT_FAILURE; // printf( "test ended successfully\n"); return EXIT_SUCCESS; }
OP_STATUS UPnPPortOpening::NotifyListenersPortClosed(UPnPDevice *device, UINT16 port, BOOL success) { OP_STATUS ops=OpStatus::OK; for(UINT i=0; i<listeners.GetCount(); i++) { UPnPPortListener *listener=(UPnPPortListener *)(listeners.Get(i)); if(listener) LAST_ERROR(ops, listener->PortClosed(upnp, device, this, port, success)); } return ops; }