MCPcopy Create free account
hub / github.com/ClusterLabs/pacemaker / mainloop_gio_callback

Function mainloop_gio_callback

lib/common/mainloop.c:551–633  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

549}
550
551static gboolean
552mainloop_gio_callback(GIOChannel *gio, GIOCondition condition, gpointer data)
553{
554 gboolean keep = TRUE;
555 mainloop_io_t *client = data;
556
557 if(condition & G_IO_IN) {
558 if(client->ipc) {
559 long rc = 0;
560 int max = 10;
561 do {
562 rc = crm_ipc_read(client->ipc);
563 if(rc <= 0) {
564 crm_trace("Message acquisition from %s[%p] failed: %s (%ld)",
565 client->name, client, pcmk_strerror(rc), rc);
566
567 } else if(client->dispatch_fn_ipc) {
568 const char *buffer = crm_ipc_buffer(client->ipc);
569 crm_trace("New message from %s[%p] = %d", client->name, client, rc, condition);
570 if(client->dispatch_fn_ipc(buffer, rc, client->userdata) < 0) {
571 crm_trace("Connection to %s no longer required", client->name);
572 keep = FALSE;
573 }
574 }
575
576 } while(keep && rc > 0 && --max > 0);
577
578 } else {
579 crm_trace("New message from %s[%p]", client->name, client);
580 if(client->dispatch_fn_io) {
581 if(client->dispatch_fn_io(client->userdata) < 0) {
582 crm_trace("Connection to %s no longer required", client->name);
583 keep = FALSE;
584 }
585 }
586 }
587 }
588
589 if(client->ipc && crm_ipc_connected(client->ipc) == FALSE) {
590 crm_err("Connection to %s[%p] closed (I/O condition=%d)", client->name, client, condition);
591 keep = FALSE;
592
593 } else if(condition & (G_IO_HUP|G_IO_NVAL|G_IO_ERR)) {
594 crm_trace("The connection %s[%p] has been closed (I/O condition=%d, refcount=%d)",
595 client->name, client, condition, mainloop_gio_refcount(client));
596 keep = FALSE;
597
598 } else if((condition & G_IO_IN) == 0) {
599 /*
600 #define GLIB_SYSDEF_POLLIN =1
601 #define GLIB_SYSDEF_POLLPRI =2
602 #define GLIB_SYSDEF_POLLOUT =4
603 #define GLIB_SYSDEF_POLLERR =8
604 #define GLIB_SYSDEF_POLLHUP =16
605 #define GLIB_SYSDEF_POLLNVAL =32
606
607 typedef enum
608 {

Callers

nothing calls this directly

Calls 5

crm_ipc_readFunction · 0.85
pcmk_strerrorFunction · 0.85
crm_ipc_bufferFunction · 0.85
crm_ipc_connectedFunction · 0.85
mainloop_gio_refcountFunction · 0.85

Tested by

no test coverage detected