/* * This is the main global destructor for the app. Call this after * _all_ libcurl usage is done. */ static void main_free(struct GlobalConfig *config) { /* Cleanup the easy handle */ curl_easy_cleanup(config->easy); config->easy = NULL; /* Main cleanup */ curl_global_cleanup(); convert_cleanup(); metalink_cleanup(); #ifdef USE_NSS if(PR_Initialized()) { /* prevent valgrind from reporting still reachable mem from NSRP arenas */ PL_ArenaFinish(); /* prevent valgrind from reporting possibly lost memory (fd cache, ...) */ PR_Cleanup(); } #endif free_config_fields(config); /* Free the config structures */ config_free(config->last); config->first = NULL; config->last = NULL; }
int main (int argc, char **argv) { static PRIntervalTime thread_start_time; static PRThread *housekeeping_tid = NULL; PLOptStatus os; PLOptState *opt = PL_CreateOptState(argc, argv, "d"); while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) { if (PL_OPT_BAD == os) continue; switch (opt->option) { case 'd': /* debug mode */ _debug_on = 1; break; default: break; } } PL_DestroyOptState(opt); if (( housekeeping_tid = PR_CreateThread (PR_USER_THREAD, housecleaning, (void*)&thread_start_time, PR_PRIORITY_NORMAL, PR_GLOBAL_THREAD, PR_UNJOINABLE_THREAD, 0)) == NULL ) { fprintf(stderr, "simple_test: Error - PR_CreateThread failed: (%ld, %ld)\n", PR_GetError(), PR_GetOSError()); exit( 1 ); } PR_Cleanup(); return(0); }
int qdevice_model_net_destroy(struct qdevice_instance *instance) { struct qdevice_net_instance *net_instance; net_instance = instance->model_data; qdevice_log(LOG_DEBUG, "Destroying algorithm"); qdevice_net_algorithm_destroy(net_instance); qdevice_log(LOG_DEBUG, "Destroying qdevice_net_instance"); qdevice_net_instance_destroy(net_instance); qdevice_log(LOG_DEBUG, "Shutting down NSS"); SSL_ClearSessionCache(); if (NSS_Shutdown() != SECSuccess) { qdevice_log_nss(LOG_WARNING, "Can't shutdown NSS"); } if (PR_Cleanup() != PR_SUCCESS) { qdevice_log_nss(LOG_WARNING, "Can't shutdown NSPR"); } free(net_instance); return (0); }
int main(int argc, char **argv) { PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0); PR_STDIO_INIT(); if (argc > 1) { count = atoi(argv[1]); } else { count = 5; } printf("\n\n%20s%30s\n\n"," ","Suspend_Resume Test"); CreateThreadsUU(); CreateThreadsUK(); CreateThreadsKU(); CreateThreadsKK(); PR_SetConcurrency(2); printf("\n%20s%30s\n\n"," ","Added 2nd CPU\n"); CreateThreadsUK(); CreateThreadsKK(); CreateThreadsUU(); CreateThreadsKU(); PR_Cleanup(); return 0; }
gboolean crypto_init (GError **error) { SECStatus ret; if (initialized) return TRUE; PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 1); ret = NSS_NoDB_Init (NULL); if (ret != SECSuccess) { g_set_error (error, NM_CRYPTO_ERROR, NM_CRYPTO_ERROR_FAILED, _("Failed to initialize the crypto engine: %d."), PR_GetError ()); PR_Cleanup (); return FALSE; } SEC_PKCS12EnableCipher(PKCS12_RC4_40, 1); SEC_PKCS12EnableCipher(PKCS12_RC4_128, 1); SEC_PKCS12EnableCipher(PKCS12_RC2_CBC_40, 1); SEC_PKCS12EnableCipher(PKCS12_RC2_CBC_128, 1); SEC_PKCS12EnableCipher(PKCS12_DES_56, 1); SEC_PKCS12EnableCipher(PKCS12_DES_EDE3_168, 1); SEC_PKCS12SetPreferredCipher(PKCS12_DES_EDE3_168, 1); initialized = TRUE; return TRUE; }
int main(int argc, char **argv) { int rv; debug_mode = 1; PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0); PR_SetThreadGCAble(); #ifdef XP_MAC SetupMacPrintfLog("thrashgc.log"); debug_mode = 1; #endif PR_InitGC(0, 0, 0, PR_GLOBAL_THREAD); PR_STDIO_INIT(); stderrLock = PR_NewLock(); tix1 = PR_RegisterType(&type1); tix2 = PR_RegisterType(&type2); tix3 = PR_RegisterType(&type3); gcInfo = PR_GetGCInfo(); rv = padMain(argc, argv); printf("PASS\n"); PR_Cleanup(); return rv; }
void lsw_nss_shutdown(void) { NSS_Shutdown(); if (!(flags & LSW_NSS_SKIP_PR_CLEANUP)) { PR_Cleanup(); } }
static int runCmd(mainTestFn fnPointer, int argc, char **argv, char *dbPath) { int retStat = 0; /* Initialize NSPR and NSS. */ PR_Init(PR_SYSTEM_THREAD, PR_PRIORITY_NORMAL, 1); /* if using databases, use NSS_Init and not NSS_NoDB_Init */ if (dbPath && PORT_Strlen(dbPath) != 0) { if (NSS_Init(dbPath) != SECSuccess) return SECFailure; } else { if (NSS_NoDB_Init(NULL) != 0) return SECFailure; } retStat = fnPointer(argc, argv); if (NSS_Shutdown() != SECSuccess) { exit(1); } PR_Cleanup(); return retStat; }
void nssCleanup (void) { /* Shutdown NSS and exit NSPR gracefully. */ NSS_Shutdown (); PR_Cleanup (); }
void crypto_global_finish(void) { NSS_Shutdown(); PL_ArenaFinish(); PR_Cleanup(); }
static void ssl_nss_uninit(void) { NSS_Shutdown(); PR_Cleanup(); _nss_methods = NULL; }
void crypto_deinit (void) { if (initialized) { NSS_Shutdown (); PR_Cleanup (); } }
int main(int argc, char **argv) { char * progName = NULL; SECStatus secStatus; PLOptState *optstate; PLOptStatus status; /* Call the NSPR initialization routines */ PR_Init( PR_SYSTEM_THREAD, PR_PRIORITY_NORMAL, 1); progName = PL_strdup(argv[0]); hostName = NULL; optstate = PL_CreateOptState(argc, argv, "d:h:i:o:p:t:"); while ((status = PL_GetNextOpt(optstate)) == PL_OPT_OK) { switch(optstate->option) { case 'd' : certDir = PL_strdup(optstate->value); break; case 'h' : hostName = PL_strdup(optstate->value); break; case 'i' : infileName = PL_strdup(optstate->value); break; case 'o' : outfileName = PL_strdup(optstate->value); break; case 'p' : port = PORT_Atoi(optstate->value); break; case 't' : trustNewServer_p = PL_strdup(optstate->value); break; case '?' : default : Usage(progName); } } if (port == 0 || hostName == NULL || infileName == NULL || outfileName == NULL || certDir == NULL) Usage(progName); #if 0 /* no client authentication */ /* Set our password function callback. */ PK11_SetPasswordFunc(myPasswd); #endif /* Initialize the NSS libraries. */ secStatus = NSS_InitReadWrite(certDir); if (secStatus != SECSuccess) { /* Try it again, readonly. */ secStatus = NSS_Init(certDir); if (secStatus != SECSuccess) exitErr("Error initializing NSS", GENERAL_ERROR); } /* All cipher suites except RSA_NULL_MD5 are enabled by Domestic Policy. */ NSS_SetDomesticPolicy(); client_main(port); NSS_Shutdown(); PR_Cleanup(); return 0; }
PR_IMPLEMENT(PRIntn) PR_Initialize( PRPrimordialFn prmain, PRIntn argc, char **argv, PRUintn maxPTDs) { PRIntn rv; _PR_ImplicitInitialization(); rv = prmain(argc, argv); PR_Cleanup(); return rv; } /* PR_Initialize */
int main(int argc, char **argv) { PRInt32 initial_threads = DEFAULT_INITIAL_THREADS; PRInt32 max_threads = DEFAULT_MAX_THREADS; PRInt32 stacksize = DEFAULT_STACKSIZE; PRThreadPool *tp = NULL; PRStatus rv; PRJob *jobp; /* * -d debug mode */ PLOptStatus os; PLOptState *opt; program_name = argv[0]; opt = PL_CreateOptState(argc, argv, "d"); while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) { if (PL_OPT_BAD == os) continue; switch (opt->option) { case 'd': /* debug mode */ _debug_on = 1; break; default: break; } } PL_DestroyOptState(opt); PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0); PR_STDIO_INIT(); PR_SetConcurrency(4); tp = PR_CreateThreadPool(initial_threads, max_threads, stacksize); if (NULL == tp) { printf("PR_CreateThreadPool failed\n"); failed_already=1; goto done; } jobp = PR_QueueJob(tp, TCP_Server, tp, PR_TRUE); rv = PR_JoinJob(jobp); PR_ASSERT(PR_SUCCESS == rv); DPRINTF(("%s: calling PR_JoinThreadPool\n", program_name)); rv = PR_JoinThreadPool(tp); PR_ASSERT(PR_SUCCESS == rv); DPRINTF(("%s: returning from PR_JoinThreadPool\n", program_name)); done: PR_Cleanup(); if (failed_already) return 1; else return 0; }
int main(int argc, char **argv) { PRThread *r, *w; PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0); PR_STDIO_INIT(); emptyBufs = PR_NewSem(2); /* two empty buffers */ fullBufs = PR_NewSem(0); /* zero full buffers */ /* Create initial temp file setup */ InitialSetup(); /* create the reader thread */ r = PR_CreateThread(PR_USER_THREAD, reader, t1, PR_PRIORITY_NORMAL, PR_LOCAL_THREAD, PR_JOINABLE_THREAD, 0); w = PR_CreateThread(PR_USER_THREAD, writer, t2, PR_PRIORITY_NORMAL, PR_LOCAL_THREAD, PR_JOINABLE_THREAD, 0); /* Do the joining for both threads */ (void) PR_JoinThread(r); (void) PR_JoinThread(w); /* Do the verification and clean up */ VerifyAndCleanup(); PR_DestroySem(emptyBufs); PR_DestroySem(fullBufs); PR_Cleanup(); if(failed_already) { printf("Fail\n"); return 1; } else { printf("PASS\n"); return 0; } }
static void atexit_handler(void) { if (PR_Initialized()) PR_Cleanup(); if (fclose(stdout)!=0) { fprintf(stderr,"Can't close stdout!\n"); exit(1); } }
void exitErr(char *function) { errWarn(function); /* Exit gracefully. */ /* ignoring return value of NSS_Shutdown as code exits with 1 anyway*/ (void) NSS_Shutdown(); PR_Cleanup(); exit(1); }
static void exitErr(const char* errorStr, int rc) { fprintf (stderr, "%s: ", errorStr); nssError(); /* Exit gracefully. */ /* ignoring return value of NSS_Shutdown. */ (void) NSS_Shutdown(); PR_Cleanup(); exit(rc); }
int main(int argc, char **argv) { char *URL; int result; #ifdef O_BINARY # ifdef __HIGHC__ _setmode(stdout, O_BINARY); # else setmode(fileno(stdout), O_BINARY); # endif #endif memory_tracking_init(); /* * Setup proper locale from environment. This is needed to enable locale- * specific behaviour by the C library in order to test for undesired side * effects that could cause in libcurl. */ #ifdef HAVE_SETLOCALE setlocale(LC_ALL, ""); #endif if(argc< 2) { fprintf(stderr, "Pass URL as argument please\n"); return 1; } test_argc = argc; test_argv = argv; if(argc>2) libtest_arg2 = argv[2]; if(argc>3) libtest_arg3 = argv[3]; URL = argv[1]; /* provide this to the rest */ fprintf(stderr, "URL: %s\n", URL); result = test(URL); #ifdef USE_NSS if(PR_Initialized()) /* prevent valgrind from reporting possibly lost memory (fd cache, ...) */ PR_Cleanup(); #endif return result; }
PR_IMPLEMENT(PRIntn) PR_Initialize( PRPrimordialFn prmain, PRIntn argc, char **argv, PRUintn maxPTDs) { #if defined(XP_MAC) #pragma unused (maxPTDs) #endif PRIntn rv; _PR_ImplicitInitialization(); rv = prmain(argc, argv); PR_Cleanup(); return rv; } /* PR_Initialize */
extern "C" am_status_t am_policy_init(am_properties_t policy_config_params) { Log::ModuleId logID = Log::addModule(AM_POLICY_SERVICE); am_status_t status = AM_SUCCESS; if (policy_config_params) { const Properties& propertiesRef = *reinterpret_cast<Properties *>(policy_config_params); try { if(enginePtr == NULL) { am_sso_init(policy_config_params); // Now try creating the policy engine. enginePtr = new PolicyEngine(propertiesRef); } else { Log::log(logID, Log::LOG_DEBUG, "Policy Service already initialized"); } } catch (const InternalException exc) { status = exc.getStatusCode(); Log::log(logID, Log::LOG_ERROR, exc); } catch (const std::bad_alloc& exc) { status = AM_NO_MEMORY; Log::log(logID, Log::LOG_ERROR, exc); } catch(std::exception &ex) { Log::log(enginePtr->getModuleID(), Log::LOG_ERROR, ex); return AM_FAILURE; } catch (...) { status = AM_FAILURE; Log::log(logID, Log::LOG_ERROR, "Unknown exception encountered."); } #if defined(USE_STATIC_NSPR) if (AM_SUCCESS != status) { PR_Cleanup(); } #endif } else { Log::log(logID, Log::LOG_DEBUG, "am_policy_init(): " "One or more invalid parameters is invalid."); status = AM_INVALID_ARGUMENT; } return status; }
int main(int argc, char **argv) { #ifdef NS_TRACE_MALLOC argc = NS_TraceMallocStartupArgs(argc, argv); #endif #ifdef CRAWL_STACK_ON_SIGSEGV strcpy(_progname,argv[0]); signal(SIGSEGV, ah_crap_handler); signal(SIGILL, ah_crap_handler); signal(SIGABRT, ah_crap_handler); #endif // CRAWL_STACK_ON_SIGSEGV #ifdef MOZ_WIDGET_GTK gtk_set_locale(); #endif gtk_init(&argc, &argv); // Initialize XPCOM nsresult rv = NS_InitXPCOM2(nsnull, nsnull, nsnull); NS_ASSERTION(NS_SUCCEEDED(rv), "NS_InitXPCOM failed"); if (NS_SUCCEEDED(rv)) { // The toolkit service in mozilla will look in the environment // to determine which toolkit to use. Yes, it is a dumb hack to // force it here, but we have no choice because of toolkit specific // code linked into the viewer. putenv("MOZ_TOOLKIT=gtk"); gTheApp = new nsNativeViewerApp(); gTheApp->Initialize(argc, argv); gTheApp->Run(); delete gTheApp; // Shutdown XPCOM rv = NS_ShutdownXPCOM(nsnull); NS_ASSERTION(NS_SUCCEEDED(rv), "NS_ShutdownXPCOM failed"); // XXX This is disabled because sometimes it hangs waiting for a // netlib thread to exit, which isn't exiting :-(. Need more // shutdown logic in necko first. #if 0 // Shutdown NSPR PR_LogFlush(); PR_Cleanup(); #endif } return 0; }
int main ( int argc, char *argv[] ) { int rv = 0; PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 14); rv = rmain(argc, argv); PR_Cleanup(); return rv; }
int main(int argc, char **argv) { /* The command line argument: -d is used to determine if the test is being run in debug mode. The regress tool requires only one line output:PASS or FAIL. All of the printfs associated with this test has been handled with a if (debug_mode) test. Usage: test_name -d */ PLOptStatus os; PLOptState *opt = PL_CreateOptState(argc, argv, "d:"); while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) { if (PL_OPT_BAD == os) continue; switch (opt->option) { case 'd': /* debug mode */ debug_mode = 1; break; default: break; } } PL_DestroyOptState(opt); /* main test */ PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0); PR_STDIO_INIT(); if (argc > 2) { count = atoi(argv[2]); } else { count = DEFAULT_COUNT; } #if defined(XP_UNIX) Measure(NativeSelectTest, "time to call 1 element select()"); #endif Measure(EmptyPRSelect, "time to call Empty PR_select()"); Measure(EmptyNativeSelect, "time to call Empty select()"); Measure(PRSelectTest, "time to call 1 element PR_select()"); if (!debug_mode) Test_Result (NOSTATUS); PR_Cleanup(); }
void main(int argc, char **argv) { PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0); PR_STDIO_INIT(); if (argc > 1) { count = atoi(argv[1]); } else { count = DEFAULT_COUNT; } Measure(statPRStat, "time to call PR_GetFileInfo()"); Measure(statStat, "time to call stat()"); PR_Cleanup(); }
int main(int argc, char **argv) { PRInt32 num_threads; /* The command line argument: -d is used to determine if the test is being run in debug mode. The regress tool requires only one line output:PASS or FAIL. All of the printfs associated with this test has been handled with a if (debug_mode) test. Usage: test_name -d */ PLOptStatus os; PLOptState *opt = PL_CreateOptState(argc, argv, "d:"); while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) { if (PL_OPT_BAD == os) continue; switch (opt->option) { case 'd': /* debug mode */ debug_mode = 1; break; default: break; } } PL_DestroyOptState(opt); /* main test */ if (argc > 2) num_threads = atoi(argv[2]); else num_threads = NUM_THREADS; PR_Init(PR_USER_THREAD, PR_PRIORITY_LOW, 0); PR_STDIO_INIT(); if (debug_mode) printf("kernel level test\n"); thread_test(PR_GLOBAL_THREAD, num_threads); PR_Cleanup(); if(failed_already) return 1; else return 0; }
int main(int argc, char **argv) { /* The command line argument: -d is used to determine if the test is being run in debug mode. The regress tool requires only one line output:PASS or FAIL. All of the printfs associated with this test has been handled with a if (debug_mode) test. Usage: test_name -d */ PLOptStatus os; PLOptState *opt = PL_CreateOptState(argc, argv, "d:"); while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) { if (PL_OPT_BAD == os) continue; switch (opt->option) { case 'd': /* debug mode */ debug_mode = 1; break; default: break; } } PL_DestroyOptState(opt); PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0); PR_STDIO_INIT(); if (argc > 1) { count = atoi(argv[1]); } else { count = DEFAULT_COUNT; } ftime_init(); Measure(timeTime, "time to get time with time()"); Measure(timeGethrtime, "time to get time with gethrtime()"); Measure(timeGettimeofday, "time to get time with gettimeofday()"); Measure(timePRTime32, "time to get time with PR_Time() (32bit)"); Measure(timePRTime64, "time to get time with PR_Time() (64bit)"); PR_Cleanup(); return 0; }
int nspr_nss_cleanup(void) { SECStatus sret; /* nothing to do */ if (nspr_nss_init_done == 0) return SECSuccess; sret = NSS_Shutdown(); if (sret != SECSuccess) { DEBUG(SSSDBG_CRIT_FAILURE, "Error shutting down connection to NSS [%d]\n", PR_GetError()); return EIO; } PR_Cleanup(); nspr_nss_init_done = 0; return EOK; }
int main(int argc, char **argv) { /* * -d debug mode */ PLOptStatus os; PLOptState *opt; program_name = argv[0]; opt = PL_CreateOptState(argc, argv, "dp:"); while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) { if (PL_OPT_BAD == os) continue; switch (opt->option) { case 'd': /* debug mode */ _debug_on = 1; break; case 'p': server_port = atoi(opt->value); break; default: break; } } PL_DestroyOptState(opt); PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0); PR_STDIO_INIT(); PR_SetConcurrency(4); TCP_Socket_Client_Server_Test(); PR_Cleanup(); if (failed_already) return 1; else return 0; }