void client_new_mbrship(ccm_info_t* info, void* borndata) { /* creating enough heap memory in order to avoid allocation */ static struct born_s bornbuffer[MAXNODE+10]; ccm_meminfo_t *ccm=(ccm_meminfo_t *)bornbuffer; struct born_s *born_arry = (struct born_s *)borndata; int n = info->memcount; int trans = info->ccm_transition_major; int* member = info->ccm_member; int i, j; assert( n<= MAXNODE); membership_ready=TRUE; ccm->ev = CCM_NEW_MEMBERSHIP; ccm->n = n; ccm->trans = trans; ccm->quorum = get_quorum(info); (void)get_quorum; ccm_debug(LOG_DEBUG, "quorum is %d", ccm->quorum); for (i = 0; i < n; i++) { ccm->member[i].index = member[i]; ccm->member[i].bornon = -1; for (j = 0; j < n; j ++) { if (born_arry[j].index == ccm->member[i].index) { ccm->member[i].bornon = born_arry[j].bornon; } } } if(ipc_mem_message && --(ipc_mem_message->count)==0){ delete_message(ipc_mem_message); } ipc_mem_message = create_message(ccm, (sizeof(ccm_meminfo_t) + n*sizeof(born_t))); ipc_mem_message->count++; refresh_llm_msg(&info->llm); #if 1 ccm_debug(LOG_DEBUG, "delivering new membership to %d clients: ", g_hash_table_size(ccm_hashclient)); if(g_hash_table_size(ccm_hashclient)){ g_hash_table_foreach(ccm_hashclient, display_func, NULL); } #else (void)display_func; #endif send_all(CCM_NEW_MEMBERSHIP); ccm_debug2(LOG_DEBUG, "membership state: new membership"); }
static void send_message(ccm_client_t *ccm_client, ccm_ipc_t *msg) { int send_rc; int do_warn = 0; struct IPC_CHANNEL *chan = ccm_client->ccm_ipc_client; ++(msg->count); do { send_rc = chan->ops->send(chan, &(msg->ipcmsg)); if (send_rc == IPC_OK) break; if (chan->ops->get_chan_status(chan) != IPC_CONNECT) { ccm_debug(LOG_WARNING, "Channel is dead. Cannot send message." " farside_pid=%u", chan->farside_pid); break; } if (10 == ++do_warn) { cl_log(LOG_WARNING, "ipc channel blocked, farside_pid=%u, reason: %s", chan->farside_pid, chan->failreason); } /* FIXME this can livelock, if a ccm client does not consume * its messages! If we want to block, why not set the channel * to blocking mode in the first place? */ cl_shortsleep(); } while(send_rc == IPC_FAIL); return; }
static void ccm_display_finalize (GObject * object) { CCMDisplay *self = CCM_DISPLAY (object); gint cpt; ccm_debug ("DISPLAY FINALIZE"); if (self == CCMDefaultDisplay) CCMDefaultDisplay = NULL; if (self->priv->registered_damage) g_object_unref (self->priv->registered_damage); if (self->priv->nb_screens) { for (cpt = 0; cpt < self->priv->nb_screens; ++cpt) { if (self->priv->screens[cpt] && CCM_IS_SCREEN (self->priv->screens[cpt])) { g_object_unref (self->priv->screens[cpt]); self->priv->screens[cpt] = NULL; } } self->priv->nb_screens = 0; g_slice_free1 (sizeof (CCMScreen *) * (self->priv->nb_screens + 1), self->priv->screens); } for (cpt = 0; cpt < CCM_DISPLAY_OPTION_N; ++cpt) g_object_unref (self->priv->options[cpt]); G_OBJECT_CLASS (ccm_display_parent_class)->finalize (object); }
static void display_func(gpointer key, gpointer value, gpointer user_data) { ccm_client_t * ccm_client = (ccm_client_t*) value; ccm_debug(LOG_DEBUG, "client: pid =%d", ccm_client->ccm_ipc_client->farside_pid); return; }
static gboolean ccm_display_init_glx(CCMDisplay *self) { g_return_val_if_fail(self != NULL, FALSE); if (glXQueryExtension (self->priv->xdisplay, &self->priv->glx.event_base, &self->priv->glx.error_base)) { self->priv->glx.available = TRUE; ccm_debug ("GLX EVENT BASE: %i", self->priv->glx.event_base); ccm_debug ("GLX ERROR BASE: %i", self->priv->glx.error_base); return TRUE; } return FALSE; }
static gboolean ccm_display_init_xfixes (CCMDisplay * self) { g_return_val_if_fail (self != NULL, FALSE); if (XFixesQueryExtension (self->priv->xdisplay, &self->priv->fixes.event_base, &self->priv->fixes.error_base)) { self->priv->fixes.available = TRUE; ccm_debug ("FIXES EVENT BASE: %i", self->priv->fixes.event_base); ccm_debug ("FIXES ERROR BASE: %i", self->priv->fixes.error_base); return TRUE; } return FALSE; }
static gboolean ccm_display_init_damage (CCMDisplay * self) { g_return_val_if_fail (self != NULL, FALSE); if (XDamageQueryExtension (self->priv->xdisplay, &self->priv->damage.event_base, &self->priv->damage.error_base)) { self->priv->damage.available = TRUE; ccm_debug ("DAMAGE EVENT BASE: %i", self->priv->damage.event_base); ccm_debug ("DAMAGE ERROR BASE: %i", self->priv->damage.error_base); return TRUE; } return FALSE; }
static gboolean ccm_display_init_composite (CCMDisplay * self) { g_return_val_if_fail (self != NULL, FALSE); if (XCompositeQueryExtension (self->priv->xdisplay, &self->priv->composite.event_base, &self->priv->composite.error_base)) { self->priv->composite.available = TRUE; ccm_debug ("COMPOSITE EVENT BASE: %i", self->priv->composite.event_base); ccm_debug ("COMPOSITE ERROR BASE: %i", self->priv->composite.error_base); return TRUE; } return FALSE; }
static int ccm_display_error_handler (Display * dpy, XErrorEvent * evt) { gchar str[128]; XGetErrorText (dpy, evt->error_code, str, 128); ccm_debug ("ERROR: Xerror: %s", str); sprintf (str, "%d", evt->request_code); XGetErrorDatabaseText (dpy, "XRequest", str, "", str, 128); if (strcmp (str, "")) ccm_debug ("ERROR: XRequest: (%s)", str); CCMLastXError = evt->error_code; ccm_debug_backtrace (); return 0; }
static void ccm_display_process_events (CCMWatch* watch) { g_return_if_fail (watch != NULL); CCMDisplay* self = CCM_DISPLAY (watch); XEvent xevent; gboolean have_create_notify = FALSE; while (!have_create_notify && XEventsQueued (CCM_DISPLAY_XDISPLAY (self), QueuedAfterReading)) { XNextEvent (CCM_DISPLAY_XDISPLAY (self), &xevent); ccm_debug ("EVENT %i", xevent.type); if (xevent.type == self->priv->damage.event_base + XDamageNotify) { XDamageNotifyEvent* event_damage = (XDamageNotifyEvent *)&xevent; CCMDamageCallback* callback; callback = (CCMDamageCallback*)ccm_set_search (self->priv->registered_damage, G_TYPE_UINT, NULL, NULL, (gpointer)event_damage->damage, (CCMSetValueCompareFunc)ccm_damage_callback_compare_with_damage); if (callback) { g_signal_emit (self, signals[DAMAGE_EVENT], 0, event_damage->damage, callback->drawable); } } else { g_signal_emit (self, signals[EVENT], 0, &xevent); if (xevent.type == CreateNotify) have_create_notify = TRUE; } } }