MCPcopy Create free account
hub / github.com/corosync/corosync / track_changes

Function track_changes

tools/corosync-cmapctl.c:515–558  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

513}
514
515static void track_changes(cmap_handle_t handle)
516{
517 struct pollfd pfd[2];
518 int cmap_fd;
519 cs_error_t err;
520 int poll_res;
521 char inbuf[3];
522 int quit = CS_FALSE;
523
524 err = cmap_fd_get(handle, &cmap_fd);
525 if (err != CS_OK) {
526 fprintf(stderr, "Failed to get file handle. Error %s\n", cs_strerror(err));
527 exit (EXIT_FAILURE);
528 }
529
530 pfd[0].fd = cmap_fd;
531 pfd[1].fd = STDIN_FILENO;
532 pfd[0].events = pfd[1].events = POLLIN;
533
534 printf("Type \"q\" to finish\n");
535 do {
536 pfd[0].revents = pfd[1].revents = 0;
537 poll_res = poll(pfd, 2, INFTIM);
538 if (poll_res == -1) {
539 perror("poll");
540 }
541
542 if (pfd[1].revents & POLLIN) {
543 if (fgets(inbuf, sizeof(inbuf), stdin) == NULL) {
544 quit = CS_TRUE;
545 } else if (strncmp(inbuf, "q", 1) == 0) {
546 quit = CS_TRUE;
547 }
548 }
549
550 if (pfd[0].revents & POLLIN) {
551 err = cmap_dispatch(handle, CS_DISPATCH_ALL);
552 if (err != CS_OK) {
553 fprintf(stderr, "Dispatch error %s\n", cs_strerror(err));
554 quit = CS_TRUE;
555 }
556 }
557 } while (poll_res > 0 && !quit);
558}
559
560static cs_error_t set_key_bin(cmap_handle_t handle, const char *key_name, const char *fname)
561{

Callers 1

mainFunction · 0.85

Calls 3

cmap_fd_getFunction · 0.85
cs_strerrorFunction · 0.85
cmap_dispatchFunction · 0.85

Tested by

no test coverage detected