void finalizar_log() { log_destroy(log_i); log_destroy(log_d); log_destroy(log_t); log_destroy(log_w); log_destroy(log_e); }
void klog_setup(klog_options_st *options, klog_metrics_st *metrics) { size_t nbuf = KLOG_NBUF; char *filename = NULL; log_info("Set up the %s module", KLOG_MODULE_NAME); if (klog_init) { log_warn("%s has already been setup, overwrite", KLOG_MODULE_NAME); log_destroy(&klogger); } klog_metrics = metrics; if (options != NULL) { filename = option_str(&options->klog_file); klog_backup = option_str(&options->klog_backup); if (klog_backup != NULL) { size_t nbyte = strnlen(klog_backup, PATH_MAX + 1); if (nbyte > PATH_MAX) { log_crit("klog file path too long"); goto error; } strncpy(backup_path, klog_backup, PATH_MAX); klog_backup = backup_path; } nbuf = option_uint(&options->klog_nbuf); klog_sample = option_uint(&options->klog_sample); if (klog_sample == 0) { log_crit("klog sample rate cannot be 0 - divide by zero"); goto error; } klog_max = option_uint(&options->klog_max); } if (filename == NULL) { /* no klog filename provided, do not log */ klog_enabled = false; return; } klogger = log_create(filename, nbuf); if (klogger == NULL) { log_crit("Could not create klogger!"); goto error; } klog_enabled = true; klog_init = true; return; error: log_destroy(&klogger); exit(EX_CONFIG); }
void liberaVariables(t_log* traceLogger, t_config* ptrConfig, t_log* errorLogger) { //Libera Logs y el Config File log_trace(traceLogger, "Se libera el Archivo de Configuracion.\n"); config_destroy(ptrConfig); log_trace(traceLogger, "Se libera el Log de Errores.\n"); log_destroy(errorLogger); log_trace(traceLogger, "Se libera el Trace Log.\n"); log_destroy(traceLogger); }
void limpiar_estructuras_swap() { log_destroy(loggerDebug); log_destroy(loggerError); log_destroy(loggerInfo); list_destroy_and_destroy_elements(metricas, free); list_destroy_and_destroy_elements(espacioLibre, free); list_destroy_and_destroy_elements(espacioOcupado, free); sem_destroy(&sem_mutex_libre); sem_destroy(&sem_mutex_ocupado); free(arch); clean_socket(socketServidor); }
int main(int argc, char **argv) { if(!check_permissions()) { exit(EXIT_FAILURE); } if((argc != 3) && (argc != 4)) { printf("usage: %s iface ttl\n", argv[0]); exit(EXIT_FAILURE); } char *iface = argv[1]; int ttl = atoi(argv[2]); int ipversion;// ipversion = 4 to IPv4; ipversion = 6 to IPv6; if(argc == 4){ ipversion = atoi(argv[3]); } else{ ipversion = 4; } log_init(LOG_EXTRA, "log.txt", 1, 1024*1024*16); struct packet *pkt; struct sender4 *s; if (ipversion == 4){ s = sender4_create(iface); pkt = sender4_send_icmp(s, 2, ttl, 1, 1, 1, 1, 1000); sender4_destroy(s); } else if (ipversion == 6){ struct sender6 *s6 = sender6_create(iface); struct libnet_in6_addr ipv6_dst; struct sockaddr_in6 sa; inet_pton(AF_INET6, "2800:3f0:4004:803::1012", &(sa.sin6_addr)); memcpy(&ipv6_dst, &sa.sin6_addr, sizeof(struct libnet_in6_addr)); pkt = sender6_send_icmp(s6, ipv6_dst, ttl, 1, 1, 1, 1, 1, 1000); sender6_destroy(s6); } char *str = packet_tostr(pkt); logd(LOG_DEBUG, "%s\n", str); free(str); packet_destroy(pkt); sleep(2); if (ipversion == 4){ pkt = sender4_send_icmp_fixrev(s, 2, ttl, 1, 1, 1, 1, 1000); } /*else if (ipversion == 6){ struct libnet_in6_addr dst_ipv6; dst_ipv6 = nameToAddr6WithSender(s, "::2"); pkt = sender_send_icmp6_fixrev(s, dst_ipv6, ttl, 1, 1, 1, 1, 1000); } str = packet_tostr(pkt); logd(LOG_DEBUG, "%s\n", str); free(str); packet_destroy(pkt);*/ log_destroy(); exit(EXIT_SUCCESS); }
static void realizarLogueo(t_log_level logLevel, int loguearEnPantalla, char *mensaje) { pthread_mutex_lock(&mutex_log); t_log *log = log_create(pathArchivoDeLog, "FILESYSTEM", loguearEnPantalla, LOG_LEVEL_TRACE); switch(logLevel) { case LOG_LEVEL_TRACE: log_trace(log, mensaje); break; case LOG_LEVEL_DEBUG: log_debug(log, mensaje); break; case LOG_LEVEL_INFO: log_info(log, mensaje); break; case LOG_LEVEL_WARNING: log_warning(log, mensaje); break; case LOG_LEVEL_ERROR: log_error(log, mensaje); break; } log_destroy(log); pthread_mutex_unlock(&mutex_log); }
int main(int argc, char*argv[]) { pthread_mutex_init(&semModificadorDeVidas, NULL); sem_init(&semReinicio, 0, 0); sem_init(&semFinPlan, 0, 0); // Inicializa el log. logger = logInit(argv, "PERSONAJE"); if (signal(SIGINT, muertoPorSenial) == SIG_ERR) { log_error(logger, "Error en el manejo de la senal de muerte del personaje.\n", stderr); exit(EXIT_FAILURE); } if (signal(SIGTERM, restarVida) == SIG_ERR) { log_error(logger, "Error en el manejo de la senal de restar vidas del personaje.\n", stderr); exit(EXIT_FAILURE); } if (signal(SIGUSR1, sig_aumentar_vidas) == SIG_ERR) { log_error(logger, "Error en el manejo de la senal de de aumentar vidas del personaje.\n", stderr); exit(EXIT_FAILURE); } // Creamos el archivo de Configuración cargarArchivoConfiguracion(argv[1]); //Me conecto con la plataforma para despues de terminar todos los niveles correctamente avisarle socketOrquestador = connectToServer(ip_plataforma, atoi(puerto_orq), logger); log_debug(logger, "El personaje se conecto con el orquestador"); //vuelve a tirar todos los hilos por todos los niveles do { log_debug(logger, "Tiro los hilos para jugar en cada nivel"); reiniciar = false; crearTodosLosHilos(); sem_wait(&semReinicio); sem_wait(&semFinPlan); //Ya terminaron todos los hilos. Si murio el ultimo me va a decir que reinicie o no. if (reiniciar) { liberarHilos(); log_debug(logger, "El personaje %c termina su conexion y reinicia todos los niveles", personaje.simbolo); } } while (reiniciar); notificarFinPlanNiveles(); cerrarConexion(&socketOrquestador); log_debug(logger, "El personaje se desconecto del orquestador"); log_destroy(logger); config_destroy(configPersonaje); list_destroy_and_destroy_elements(personaje.lPersonajes, (void*) _liberar_personaje_individual); exit(EXIT_SUCCESS); }
int main(int argc, char **argv) { const uint16_t acceptor_port = (uint16_t)((argc >= 2) ? atoi(argv[1]) : 8080); char const * const settings_file_name = ((argc >= 3) ? argv[2] : "settings.txt"); settings_t settings; server_t server; log_t log; log_create(&log, stderr); if (!load_settings(&settings, settings_file_name, &log)) { return 1; } if (!server_create(&server, &log, &settings, acceptor_port)) { settings_destroy(&settings); return 1; } settings_destroy(&settings); server_run(&server); server_destroy(&server); log_destroy(&log); return 0; }
int main(int argc, char *argv[]) { signal(SIGUSR1, (void*) manejarSenial); logger = log_create("/home/utnso/personaje.log", "PERSONAJE", true, LOG_LEVEL_TRACE); log_info(logger, "Log creado con exito, se procede a loguear el proceso Personaje"); log_debug(logger, "Chequeando el path del personaje..."); if (argv[1] == NULL ) { log_error(logger, "El path del personaje no puede ser vacio."); log_destroy(logger); return EXIT_FAILURE; } path = argv[1]; int levantarConfig = levantarPersonaje(path); if (levantarConfig == 1) { return EXIT_FAILURE; } enviarSeniales(); int resultado = procesar(); if (resultado == 1) { return EXIT_FAILURE; } finalizar(); return EXIT_SUCCESS; }
int main(int argc, char *argv[]) { logger = log_create("Log.txt", "NODO", false, LOG_LEVEL_DEBUG); fd = socket_listen(30123); sock_job = socket_accept(fd); log_info(logger,"fd : %d", fd); log_info(logger,"conexion job: %d", sock_job); int hand = socket_handshake_to_client(sock_job, HANDSHAKE_NODO, HANDSHAKE_JOB); if (!hand) { printf("Error al conectar con Job \n"); return EXIT_FAILURE; } void *buffer; size_t sbuffer = 0; int recibi; recibi = socket_recv_packet(sock_job, &buffer, &sbuffer); log_info(logger,"Recibi todo ok : %d\n",recibi); desserializeMap(buffer); /* recvOrder(fd); serializeMapResult(fd, true, 1); recvOrder(fd); char failedTemp[60]; memset(failedTemp, '\0', sizeof(char) * 60); strcpy(failedTemp, "TemporalFallido"); serializeReduceResult(fd, false, 0, failedTemp); recvOrder(fd); */ log_destroy(logger); return EXIT_SUCCESS; }
void finalizar() { close(socketNivel); close(socketPlanificador); log_debug(logger, "El personaje %s finalizo sus niveles de forma correcta.", personaje->nombre); avisarFinalizacionDelPersonaje(); // le avisa al orquestador que termino el plan de niveles log_destroy(logger); }
void destroyOnConnectionFailure() { close(umvSocket); close(pcpSocket); log_destroy(logger); config_destroy(configuracion_CPU); exit(EXIT_FAILURE); }
void system_destroy() { log_destroy(); endwin(); Pa_Terminate(); }
int main(int argc, char *argv[]) { jobConfig = config_create(FILE_CONFIG); logger = log_create(FILE_LOG, "JOB", true, LOG_LEVEL_TRACE); pthread_mutex_init(&mutex_log, NULL); signal(SIGCHLD, SIG_IGN); //sem_t sem; sem_init(&sem, 0, 0); //test conexion con marta conectar_con_marta(); log_trace(logger, "FIN TODO"); /* cleanup semaphores */ sem_destroy (&sem); //desconecto al nodo /*int socket = client_socket("192.168.1.37", 6001); t_msg* msg = argv_message(-1, 0); enviar_mensaje(socket, msg); destroy_message(msg); close(socket);*/ //finalizo el programa para que no intente conectar con el nodo log_destroy(logger); config_destroy(jobConfig); return EXIT_SUCCESS; }
/* * Log function taking a format and variable number of arguments fitting the * given format. */ static void _log_write(char *buf, size_t len) { int ret; assert(buf); assert(logconfig.fp); /* Make sure buffer is NULL terminated. */ buf[len - 1] = '\0'; ret = fprintf(logconfig.fp, "%s", buf); if (ret < 0) { fprintf(stderr, "[tsocks] logging failed. Stopping logging.\n"); log_destroy(); goto end; } /* * On a write failure we stop the logging but a flush failure is not that * critical. */ (void) fflush(logconfig.fp); end: return; }
static void jfs_destroy(void *arg) { int rc; /* stop all reads */ jfs_pool_destroy(jfs_read_pool); /* let writes propogate */ jfs_pool_wait(jfs_write_pool); jfs_pool_destroy(jfs_write_pool); rc = sqlite3_shutdown(); if(rc != SQLITE_OK) { log_error("SQLITE shutdown FAILED!!!\n"); } jfs_datapath_cache_destroy(); jfs_key_cache_destroy(); jfs_meta_cache_destroy(); jfs_dynamic_hierarchy_destroy(); free(joinfs_context.querypath); free(joinfs_context.mountpath); free(joinfs_context.logpath); free(joinfs_context.dbpath); log_msg("joinFS shutdown completed successfully.\n", arg); log_destroy(); }
void log_close(LOG_REC *log) { g_return_if_fail(log != NULL); log_remove_config(log); log_destroy(log); }
t_queue* enviarRecursoOrquestador(recursosPersonajesStruct *unPersonaje) { t_log *log = log_create(logName,"Nivel",FALSE,LOG_LEVEL_INFO); int32_t length,size; liberadosNoSerializadoStruct colaLib; colaNoSerializadaStruct *colaAsig; nivelYPersonaje nivelYPersonaje; colaLib.cola=unPersonaje->recursos; void *data = serializador_liberados(&colaLib,&size); length = size + sizeof(header_t); int32_t socketOrquestador = socketCreateClient(getIp(nivel.orquestador), getPort(nivel.orquestador)); nivelYPersonaje.personaje = unPersonaje->simbolo; strcpy(nivelYPersonaje.nivelNombre,nivel.nombre); socketSend(socketOrquestador, data, length); socketSend(socketOrquestador, &(nivelYPersonaje), sizeof(char[30])); recv(socketOrquestador,&length,sizeof(int32_t),MSG_WAITALL); void *buffer = malloc(length); recv(socketOrquestador,buffer,length,MSG_WAITALL); colaAsig = desserializador_recursos(buffer); shutdown(socketOrquestador,2); log_destroy(log); return colaAsig->cola; }
void exitFileSystem() { list_destroy(listaArchivos); log_destroy(logFile); cerrarConexiones(); exit(0); }
/** * @brief Free any memory associated with a scheduler_t. * * This will stop the interface if it is currently running, and free all the * memory associated with the different regular expression and similar * structures. * * @param scheduler */ void scheduler_destroy(scheduler_t* scheduler) { // TODO interface close // TODO repo close event_loop_destroy(); if(scheduler->main_log) { log_destroy(scheduler->main_log); main_log = NULL; } if(scheduler->process_name) g_free(scheduler->process_name); if(scheduler->sysconfig) fo_config_free(scheduler->sysconfig); if(scheduler->sysconfigdir) g_free(scheduler->sysconfigdir); if(scheduler->host_queue) g_list_free(scheduler->host_queue); if(scheduler->workers) g_thread_pool_free(scheduler->workers, FALSE, TRUE); if(scheduler->email_subject) g_free(scheduler->email_subject); if(scheduler->email_command) g_free(scheduler->email_command); g_sequence_free(scheduler->job_queue); g_regex_unref(scheduler->parse_agent_msg); g_regex_unref(scheduler->parse_db_email); g_regex_unref(scheduler->parse_interface_cmd); g_tree_unref(scheduler->meta_agents); g_tree_unref(scheduler->agents); g_tree_unref(scheduler->host_list); g_tree_unref(scheduler->job_list); g_free(scheduler); }
void filesystem_shutdown() { mongo_dir_shutdown(); mongo_file_shutdown(); mongo_node_shutdown(); mongo_shutdown(); log_destroy(mdfs_logger); }
Track::~Track ( ) { Loggable::block_start(); /* must destroy sequences first to preserve proper log order */ takes->clear(); control->clear(); annotation->clear(); delete sequence(); takes = NULL; control = NULL; annotation = NULL; log_destroy(); /* ensure that soloing accounting is performed */ solo( false ); timeline->remove_track( this ); /* give up our ports */ configure_inputs( 0 ); configure_outputs( 0 ); _sequence = NULL; if ( _name ) free( _name ); Loggable::block_end(); }
void logearOrdenReduce(char* nombre){ t_log_level nivel; t_log* archivoDeLog; nivel = LOG_LEVEL_INFO; archivoDeLog = log_create("LogNodo", "Nodo", 0, nivel); char *unaPalabra = string_new(); string_append(&unaPalabra, "Solicitud de Reduce con el script "); string_append(&unaPalabra, nombre); log_info(archivoDeLog,unaPalabra); free(unaPalabra); log_destroy(archivoDeLog); }
int main(int argc,char *argv[]) { t_configuracion_cpu* configCPU = malloc(sizeof(t_configuracion_cpu)); logger = log_create("cpu.log", "CPU",true, LOG_LEVEL_INFO); crearLog(); //valida los parametros de entrada del main if (argc != 2) { log_error_y_cerrar_logger(logger, "Uso: cpu config_path (faltan parametros de entrada)\n"); return EXIT_FAILURE; } log_info(logger, "Inciando proceso CPU.."); levantarDatosDeConfiguracion(configCPU, argv[1]); //Conexión al nucleo conectarAlNucleo(configCPU); //Conexión al umc conectarAUMC(configCPU); signal(SIGUSR1, handler_seniales); int header; printf("Me quedo escuchando mensajes del nucleo (socket:%d)\n", socket_nucleo); while(1){ if( recv(socket_nucleo, &header, sizeof(int), 0) <= 0) { perror("Desconexion del nucleo\n"); close(socket_nucleo); return 0; } switch (header) { case EJECUTA: ejecutar(); break; case CAMBIO_QUANTUM_SLEEP: recv(socket_nucleo,&quantum_sleep,sizeof(int),0); break; default: printf("obtuve otro id %d\n", header); sleep(3); break; } } finalizarCpu(); log_destroy(logger); return EXIT_SUCCESS; }
void liberarRecusos() { // liberar otros recursos liberarEstructura(); free(tablaPaginas); tablaPaginas = NULL; free(tablaDeBitMap); tablaDeBitMap = NULL; log_destroy(logger); logger = NULL; fclose(archivoSwap); }
/* * Initialize joinFS. */ static void * jfs_init(struct fuse_conn_info *conn) { struct sched_param param; pthread_attr_t wattr; log_init(); log_msg("Starting joinFS. FUSE Major=%d Minor=%d\n", conn->proto_major, conn->proto_minor); /* initialize caches */ jfs_dynamic_path_init(); jfs_datapath_cache_init(); jfs_key_cache_init(); jfs_meta_cache_init(); jfs_init_db(); jfs_read_pool = jfs_pool_create(JFS_THREAD_MIN, JFS_THREAD_MAX, JFS_THREAD_LINGER, NULL, SQLITE_OPEN_READONLY); if(!jfs_read_pool) { log_error("Failed to allocate READ pool.\n"); log_destroy(); exit(EXIT_FAILURE); } pthread_attr_init(&wattr); pthread_attr_setschedpolicy(&wattr, SCHED_RR); pthread_attr_getschedparam(&wattr, ¶m); param.sched_priority = 1; pthread_attr_setschedparam(&wattr, ¶m); jfs_write_pool = jfs_pool_create(1, 1, JFS_THREAD_LINGER, &wattr, SQLITE_OPEN_READWRITE); if(!jfs_write_pool) { log_error("Failed to allocate WRITE pool.\n"); log_destroy(); exit(EXIT_FAILURE); } log_msg("joinFS Thread pools started.\n"); return NULL; }
JACK_Module::~JACK_Module ( ) { log_destroy(); configure_inputs( 0 ); configure_outputs( 0 ); if ( _prefix ) free( _prefix ); }
Controller_Module::~Controller_Module ( ) { Fl::remove_timeout( update_cb, this ); log_destroy(); /* shutdown JACK port, if we have one */ mode( GUI ); }
Cursor_Point::~Cursor_Point ( ) { // sequence()->remove( this ); log_destroy(); label(NULL); type(NULL); }
/* * Lib destructor. */ static void tsocks_exit(void) { /* Cleanup every entries in the onion pool. */ onion_pool_destroy(&tsocks_onion_pool); /* Cleanup allocated memory in the config file. */ config_file_destroy(&tsocks_config.conf_file); /* Clean up logging. */ log_destroy(); }