static gboolean cl_respawn_quit(int signo, gpointer user_data) { shutting_down = TRUE; if (monitored_PID != 0) { cl_log(LOG_INFO, "Killing pid [%d] with SIGTERM" , monitored_PID); /* DisableProcLogging(); */ if (kill(monitored_PID, SIGTERM) < 0) { monitored_PID=0; }else{ return TRUE; } } if (mainloop != NULL && g_main_is_running(mainloop)) { DisableProcLogging(); g_main_quit(mainloop); } else { apphb_unregister(); DisableProcLogging(); exit(LSB_EXIT_OK); } return TRUE; }
gboolean check_sigint ( GMainLoop *loop ) { if (caught_sigint) { g_message( "Caught SIGINT!" ); g_main_quit( loop ); } return TRUE; }
gboolean jabber_source_dispatch(GSource *source, GSourceFunc callback, gpointer user_data){ if (stop_it && stream){ if (stop_it>1){ stream_destroy(stream); stream=NULL; g_main_quit(main_loop); } stop_it++; } else if (stream==NULL) g_main_quit(main_loop); return TRUE; }
void cibadmin_op_callback(xmlNode * msg, int call_id, int rc, xmlNode * output, void *user_data) { exit_code = rc; if (rc != 0) { crm_warn("Call %s failed (%d): %s", cib_action, rc, pcmk_strerror(rc)); fprintf(stderr, "Call %s failed (%d): %s\n", cib_action, rc, pcmk_strerror(rc)); print_xml_output(output); } else if (safe_str_eq(cib_action, CIB_OP_QUERY) && output == NULL) { crm_err("Output expected in query response"); crm_log_xml_err(msg, "no output"); } else if (output == NULL) { crm_info("Call passed"); } else { crm_info("Call passed"); print_xml_output(output); } if (call_id == request_id) { g_main_quit(mainloop); } else { crm_info("Message was not the response we were looking for (%d vs. %d", call_id, request_id); } }
void cib_connection_destroy(gpointer user_data) { crm_err("Connection to the CIB terminated... exiting"); g_main_quit(mainloop); return; }
static void test_done(void) { counter++; if (counter == 2) g_main_quit(loop); }
static void _action_call_function_got_response(SoupSession * session, SoupMessage * msg, gpointer user_data) { SyncNetAction *sna = (SyncNetAction *) user_data; gchar *string; if ((string = _soup_get_xmlrpc_value_string(msg, sna)) && sna->entry->save_to) { DEBUG("received string: %s\n", string); gchar *filename = g_build_filename(g_get_home_dir(), ".hardinfo", sna->entry->save_to, NULL); DEBUG("saving to %s", filename); g_file_set_contents(filename, string, -1, NULL); g_free(filename); } if (sna->entry->callback) { sna->entry->callback(sna->entry, string); } g_free(string); g_main_quit(loop); }
void notify_crmd(crm_graph_t *graph) { HA_Message *cmd = NULL; int log_level = LOG_DEBUG; const char *op = CRM_OP_TEABORT; int pending_callbacks = num_cib_op_callbacks(); stop_te_timer(transition_timer); if(pending_callbacks != 0) { crm_warn("Delaying completion until all CIB updates complete"); return; } CRM_CHECK(graph->complete, graph->complete = TRUE); switch(graph->completion_action) { case tg_stop: op = CRM_OP_TECOMPLETE; log_level = LOG_INFO; break; case tg_abort: case tg_restart: op = CRM_OP_TEABORT; break; case tg_shutdown: crm_info("Exiting after transition"); if (mainloop != NULL && g_main_is_running(mainloop)) { g_main_quit(mainloop); return; } exit(LSB_EXIT_OK); } te_log_action(log_level, "Transition %d status: %s - %s", graph->id, op, crm_str(graph->abort_reason)); print_graph(LOG_DEBUG_3, graph); cmd = create_request( op, NULL, NULL, CRM_SYSTEM_DC, CRM_SYSTEM_TENGINE, NULL); if(graph->abort_reason != NULL) { ha_msg_add(cmd, "message", graph->abort_reason); } send_ipc_message(crm_ch, cmd); crm_msg_del(cmd); graph->abort_reason = NULL; graph->completion_action = tg_restart; }
void cib_connection_destroy(gpointer user_data) { cib_t *conn = user_data; crm_err("Connection to the CIB terminated... exiting"); conn->cmds->signoff(conn); /* Ensure IPC is cleaned up */ g_main_quit(mainloop); return; }
void shutdown_quorumd(void) { quorum_log(LOG_INFO,"quorumd is shutting down"); if (mainloop != NULL && g_main_is_running(mainloop)) { g_main_quit(mainloop); }else { exit(LSB_EXIT_OK); } }
gboolean admin_message_timeout(gpointer data) { fprintf(stderr, "No messages received in %d seconds.. aborting\n", (int)message_timeout_ms / 1000); crm_err("No messages received in %d seconds", (int)message_timeout_ms / 1000); operation_status = -3; g_main_quit(mainloop); return FALSE; }
void crmadmin_ipc_connection_destroy(gpointer user_data) { crm_err("Connection to CRMd was terminated"); if (mainloop) { g_main_quit(mainloop); } else { exit(1); } }
static void attrd_shutdown(int nsig) { shutting_down = TRUE; crm_info("Shutting down"); if (mloop != NULL && g_main_is_running(mloop)) { g_main_quit(mloop); } else { crm_exit(pcmk_ok); } }
gboolean check_exit_signal ( GMainLoop *loop ) { if (exit_signal) { g_message( "Caught exit signal %d!", exit_signal ); if (pid_file != NULL) { unlink( NC_PID_FILE ); fclose( pid_file ); } g_main_quit( loop ); } return TRUE; }
static void attrd_shutdown(int nsig) { need_shutdown = TRUE; crm_info("Exiting"); if (mainloop != NULL && g_main_is_running(mainloop)) { g_main_quit(mainloop); } else { exit(0); } }
void cibadmin_op_callback(xmlNode *msg, int call_id, int rc, xmlNode *output, void *user_data) { char *admin_input_xml = NULL; exit_code = rc; if(output != NULL) { admin_input_xml = dump_xml_formatted(output); } if(safe_str_eq(cib_action, CIB_OP_ISMASTER) && rc != cib_ok) { crm_info("CIB on %s is _not_ the master instance", host?host:"localhost"); fprintf(stderr, "CIB on %s is _not_ the master instance\n", host?host:"localhost"); } else if(safe_str_eq(cib_action, CIB_OP_ISMASTER)) { crm_info("CIB on %s _is_ the master instance", host?host:"localhost"); fprintf(stderr, "CIB on %s _is_ the master instance\n", host?host:"localhost"); } else if(rc != 0) { crm_warn("Call %s failed (%d): %s", cib_action, rc, cib_error2string(rc)); fprintf(stderr, "Call %s failed (%d): %s\n", cib_action, rc, cib_error2string(rc)); fprintf(stdout, "%s\n", crm_str(admin_input_xml)); } else if(safe_str_eq(cib_action, CIB_OP_QUERY) && output==NULL) { crm_err("Output expected in query response"); crm_log_xml(LOG_ERR, "no output", msg); } else if(output == NULL) { crm_info("Call passed"); } else { crm_info("Call passed"); fprintf(stdout, "%s\n", crm_str(admin_input_xml)); } crm_free(admin_input_xml); if(call_id == request_id) { g_main_quit(mainloop); } else { crm_info("Message was not the response we were looking for (%d vs. %d", call_id, request_id); } }
static void _action_check_api_version_got_response(SoupMessage * msg, gpointer user_data) { SyncNetAction *sna = (SyncNetAction *) user_data; long version = _soup_get_xmlrpc_value_int(msg, sna); if (version != XMLRPC_SERVER_API_VERSION) { SNA_ERROR(5, "Server says it supports API version %ld, but " "this version of HardInfo only supports API " "version %d.", version, XMLRPC_SERVER_API_VERSION); } g_main_quit(loop); }
static void xmlrpc_response_get_array(SoupSession *s, SoupMessage *m, gpointer user_data) { if (SOUP_STATUS_IS_SUCCESSFUL(m->status_code)) { soup_xmlrpc_extract_method_response(m->response_body->data, m->response_body->length, NULL, G_TYPE_VALUE_ARRAY, user_data); } g_main_quit(loop); lock = FALSE; }
static gboolean _cancel_sync(GtkWidget * widget, gpointer data) { SyncDialog *sd = (SyncDialog *) data; if (session) { soup_session_abort(session); } sd->flag_cancel = TRUE; g_main_quit(loop); gtk_widget_set_sensitive(widget, FALSE); return FALSE; }
static gboolean logd_term_action(int sig, gpointer userdata) { GList *log_iter = logd_client_list; GMainLoop *mainloop = (GMainLoop*)userdata; ha_logd_client_t *client = NULL; cl_log(LOG_DEBUG, "logd_term_action: received SIGTERM"); if (mainloop == NULL){ cl_log(LOG_ERR, "logd_term_action: invalid arguments"); return FALSE; } stop_reading = TRUE; while(log_iter != NULL) { client = log_iter->data; log_iter = log_iter->next; cl_log(LOG_DEBUG, "logd_term_action:" " waiting for %d messages to be read for process %s", (int)client->logchan->send_queue->current_qlen, client->app_name); client->logchan->ops->waitout(client->logchan); } cl_log(LOG_DEBUG, "logd_term_action" ": waiting for %d messages to be read by write process" , (int)chanspair[WRITE_PROC_CHAN]->send_queue->current_qlen); chanspair[WRITE_PROC_CHAN]->ops->waitout(chanspair[WRITE_PROC_CHAN]); cl_log(LOG_DEBUG, "logd_term_action: sending SIGTERM to write process"); if (CL_KILL(write_process_pid, SIGTERM) >= 0){ pid_t pid; pid = wait4(write_process_pid, NULL, 0, NULL); if (pid < 0){ cl_log(LOG_ERR, "wait4 for write process failed"); } } g_main_quit(mainloop); return TRUE; }
static void stonith_peer_hb_destroy(gpointer user_data) { if(stonith_shutdown_flag) { crm_info("Heartbeat disconnection complete... exiting"); } else { crm_err("Heartbeat connection lost! Exiting."); } crm_info("Exiting..."); if (mainloop != NULL && g_main_is_running(mainloop)) { g_main_quit(mainloop); } else { exit(LSB_EXIT_OK); } }
static void xmlrpc_response_get_integer(SoupSession *s, SoupMessage *m, gpointer user_data) { gint *response = user_data; *response = -1; if (SOUP_STATUS_IS_SUCCESSFUL(m->status_code)) { soup_xmlrpc_extract_method_response(m->response_body->data, m->response_body->length, NULL, G_TYPE_INT, response); } g_main_quit(loop); lock = FALSE; }
static void sig_exit(void) { g_main_quit(main_loop); }
static void close_clicked(void) { g_main_quit(loop); }
void b_main_quit() { g_main_quit( loop ); }
static gboolean direct_log(IPC_Channel* ch, gpointer user_data) { IPC_Message* ipcmsg; GMainLoop* loop; int pri = LOG_DEBUG + 1; loop =(GMainLoop*)user_data; while(ch->ops->is_message_pending(ch)){ if (ch->ch_status == IPC_DISCONNECT){ cl_log(LOG_ERR, "read channel is disconnected:" "something very wrong happened"); return FALSE; } ipcmsg = getIPCmsg(ch); if (ipcmsg == NULL){ return TRUE; } if( ipcmsg->msg_body && ipcmsg->msg_len > 0 ){ LogDaemonMsgHdr *logmsghdr; LogDaemonMsgHdr copy; char *msgtext; logmsghdr = (LogDaemonMsgHdr*) ipcmsg->msg_body; /* this copy nonsense is here because apparently ia64 * complained about "unaligned memory access. */ #define COPYFIELD(copy, msg, field) memcpy(((u_char*)©.field), ((u_char*)&msg->field), sizeof(copy.field)) COPYFIELD(copy, logmsghdr, use_pri_str); COPYFIELD(copy, logmsghdr, entity); COPYFIELD(copy, logmsghdr, entity_pid); COPYFIELD(copy, logmsghdr, timestamp); COPYFIELD(copy, logmsghdr, priority); /* Don't want to copy the following message text */ msgtext = (char *)logmsghdr + sizeof(LogDaemonMsgHdr); cl_direct_log(copy.priority, msgtext , copy.use_pri_str , copy.entity, copy.entity_pid , copy.timestamp); if (copy.priority < pri) pri = copy.priority; (void)logd_log; /* if (verbose){ logd_log("%s[%d]: %s %s\n", logmsg->entity[0]=='\0'? "unknown": copy.entity, copy.entity_pid, ha_timestamp(copy.timestamp), msgtext); } */ if (ipcmsg->msg_done){ ipcmsg->msg_done(ipcmsg); } } } /* current message backlog processed, * about to return to mainloop, * fflush and potentially fsync stuff */ cl_log_do_fflush(pri <= LOG_ERR); if(needs_shutdown) { cl_log(LOG_INFO, "Exiting write process"); g_main_quit(loop); return FALSE; } return TRUE; }