static void on_geany_startup_complete(G_GNUC_UNUSED GObject *obj, G_GNUC_UNUSED gpointer user_data) { if (check_on_startup == TRUE) { update_check(UPDATECHECK_STARTUP); } }
static void statsd_handle_payload(noit_check_t **checks, int nchecks, char *payload, int len) { char *cp, *ecp, *endptr; cp = ecp = payload; endptr = payload + len - 1; while(ecp != NULL && ecp < endptr) { int i, idx = 0, last_space = 0; char key[256], *value; const char *type = NULL; ecp = memchr(ecp, '\n', len - (ecp - payload)); if(ecp) *ecp++ = '\0'; while(idx < sizeof(key) - 2 && *cp != '\0' && *cp != ':') { if(isspace(*cp)) { if(!last_space) key[idx++] = '_'; cp++; last_space = 1; continue; } else if(*cp == '/') key[idx++] = '-'; else if((*cp >= 'a' && *cp <= 'z') || (*cp >= 'A' && *cp <= 'Z') || (*cp >= '0' && *cp <= '9') || *cp == '`' || *cp == '.' || *cp == '_' || *cp == '-') { key[idx++] = *cp; } last_space = 0; cp++; } key[idx] = '\0'; while((NULL != cp) && NULL != (value = strchr(cp, ':'))) { double sampleRate = 1.0; double diff = 1.0; if(value) { *value++ = '\0'; cp = strchr(value, '|'); if(cp) { char *sample_string; *cp++ = '\0'; type = cp; sample_string = strchr(type, '|'); if(sample_string) { *sample_string++ = '\0'; if(*sample_string == '@') sampleRate = strtod(sample_string + 1, NULL); } if(*type == 'g') { diff = 0.0; } else if(0 == strcmp(type, "ms")) { diff = 0.0; } else { type = NULL; } } diff = strtod(value, NULL); } if(type == NULL) type = COUNTER_STRING; switch(*type) { case 'g': case 'c': case 'm': for(i=0;i<nchecks;i++) update_check(checks[i], key, *type, diff, sampleRate); break; default: break; } cp = value; } cp = ecp; } }
static void manual_check_activated_cb(GtkMenuItem *menuitem, gpointer gdata) { update_check(UPDATECHECK_MANUAL); }
/* * We periodically check here what actions happened in this "time-slice". * This can be: * - dpkg_was_run=TRUE: set when apt wrote the "dpkg-run-stamp" file * - apt_get_running: set when apt/dpkg activity is detected (in the * lists-dir, archive-cache, or /var/lib/dpkg/status) * - hook_pending: we have new upgrade hoook information * - reboot_pending: we need to reboot * - crashreport_pending: we have a new crashreport * - unicast_local_avahi_pending: avahi got disabled due to a unicast .local domain * */ static gboolean file_monitor_periodic_check(gpointer data) { UpgradeNotifier *un = (UpgradeNotifier *)data; // we are not ready yet, wait for the next timeslice if((un->reboot == NULL) || (un->crashreport == NULL)) return TRUE; // DPkg::Post-Invoke has written a stamp file, that means an install/remove // operation finished, we can show hooks/reboot notifications then if(un->dpkg_was_run) { // check updates update_check(un->update); // run cache-changed plugin scripts GDir *dir = g_dir_open(CACHE_CHANGED_PLUGIN_DIR, 0, NULL); const gchar *fname, *full_path; GSList *cache_changed_scripts = NULL; while ( (fname = g_dir_read_name(dir)) != NULL ) { full_path = g_build_filename(CACHE_CHANGED_PLUGIN_DIR, fname, NULL); cache_changed_scripts = g_slist_insert_sorted(cache_changed_scripts, (gpointer)full_path, (GCompareFunc)g_strcmp0); } g_dir_close(dir); // launch first script and queue others start_next_script(0, 0, cache_changed_scripts); // any apt-get update must be finished, otherwise // apt-get install wouldn't be finished update_apt_is_running(un->update, FALSE); if(un->update_finished_timer > 0) g_source_remove(un->update_finished_timer); if(un->reboot_pending) { //g_print("checking reboot now\n"); reboot_check (un->reboot); un->reboot_pending = FALSE; } // apt must be finished when a new stamp file was written, so we // reset the apt_get_running time-slice field because its not // important anymore (it finished running) // // This may leave a 5s race condition when a apt-get install finished // and something new (apt-get) was started un->apt_get_running = FALSE; un->last_apt_action = 0; } // show pending hooks if(un->hook_pending) { //g_print("checking hooks now\n"); check_update_hooks(un->hook); un->hook_pending = FALSE; } // apt-get update/install or dpkg is running (and updates files in // its list/cache dir) or in /var/lib/dpkg/status if(un->apt_get_running) update_apt_is_running(un->update, TRUE); // update time information for apt/dpkg time_t now = time(NULL); if(un->apt_get_running) un->last_apt_action = now; // no apt operation for a long time if(un->last_apt_action > 0 && (now - un->last_apt_action) > TIMEOUT_APT_RUN) { update_apt_is_running(un->update, FALSE); update_check(un->update); un->last_apt_action = 0; } if(un->crashreport_pending) { g_debug("checking for valid crashreport now"); crashreport_check (un->crashreport); un->crashreport_pending = FALSE; } if(un->unicast_local_avahi_pending) { g_debug("checking for disabled avahi due to unicast .local domain now"); avahi_disabled_check (); un->unicast_local_avahi_pending = FALSE; } // reset the bitfields (for the next "time-slice") un->dpkg_was_run = FALSE; un->apt_get_running = FALSE; return TRUE; }