1    	/*
2    	 * Copyright 2004-2012 Red Hat, Inc.
3    	 *
4    	 * This copyrighted material is made available to anyone wishing to use,
5    	 * modify, copy, or redistribute it subject to the terms and conditions
6    	 * of the GNU General Public License v2 or (at your option) any later version.
7    	 */
8    	
9    	#include <stdio.h>
10   	#include <stdlib.h>
11   	#include <unistd.h>
12   	#include <stdint.h>
13   	#include <string.h>
14   	#include <errno.h>
15   	#include <time.h>
16   	#include <sys/types.h>
17   	#include <sys/socket.h>
18   	#include <sys/un.h>
19   	
20   	#include <linux/dlmconstants.h>
21   	#include "dlm_controld.h"
22   	#include "libdlmcontrol.h"
23   	
24   	static int do_read(int fd, void *buf, size_t count)
25   	{
26   		int rv, off = 0;
27   	
28   		while (off < count) {
29   			rv = read(fd, (char *)buf + off, count - off);
30   			if (rv == 0)
31   				return -1;
32   			if (rv == -1 && errno == EINTR)
33   				continue;
34   			if (rv == -1)
35   				return -1;
36   			off += rv;
37   		}
38   		return 0;
39   	}
40   	
41   	static int do_write(int fd, void *buf, size_t count)
42   	{
43   		int rv, off = 0;
44   	
45   	 retry:
46   		rv = write(fd, (char *)buf + off, count);
47   		if (rv == -1 && errno == EINTR)
48   			goto retry;
49   		if (rv < 0) {
50   			return rv;
51   		}
52   	
53   		if (rv != count) {
54   			count -= rv;
55   			off += rv;
56   			goto retry;
57   		}
58   		return 0;
59   	}
60   	
61   	static int do_connect(const char *sock_path)
62   	{
63   		struct sockaddr_un sun;
64   		socklen_t addrlen;
65   		int rv, fd;
66   	
67   		fd = socket(PF_UNIX, SOCK_STREAM, 0);
68   		if (fd < 0)
69   			goto out;
70   	
71   		memset(&sun, 0, sizeof(sun));
72   		sun.sun_family = AF_UNIX;
73   		strcpy(&sun.sun_path[1], sock_path);
74   		addrlen = sizeof(sa_family_t) + strlen(sun.sun_path+1) + 1;
75   	
76   		rv = connect(fd, (struct sockaddr *) &sun, addrlen);
77   		if (rv < 0) {
78   			close(fd);
79   			fd = rv;
80   		}
81   	 out:
82   		return fd;
83   	}
84   	
85   	static inline void init_header_name(struct dlmc_header *h,
86   					    const char *name, size_t len)
87   	{
88   	#pragma GCC diagnostic push
89   	#if __GNUC__ >= 8
90   	#pragma GCC diagnostic ignored "-Wstringop-truncation"
91   	#endif
92   		strncpy(h->name, name, len);
93   	#pragma GCC diagnostic pop
94   	}
95   	
96   	static void init_header(struct dlmc_header *h, int cmd, char *name,
97   				int extra_len)
98   	{
99   		memset(h, 0, sizeof(struct dlmc_header));
100  	
101  		h->magic = DLMC_MAGIC;
102  		h->version = DLMC_VERSION;
103  		h->len = sizeof(struct dlmc_header) + extra_len;
104  		h->command = cmd;
105  	
106  		if (name)
107  			init_header_name(h, name, DLM_LOCKSPACE_LEN);
108  	}
109  	
110  	static char copy_buf[DLMC_DUMP_SIZE];
111  	
112  	static int do_dump(int cmd, char *name, char *buf, int *data)
113  	{
114  		struct dlmc_header h;
115  		int fd, rv, len;
116  	
117  		memset(copy_buf, 0, DLMC_DUMP_SIZE);
118  	
119  		init_header(&h, cmd, name, 0);
120  	
121  		*data = 0;
122  	
123  		fd = do_connect(DLMC_QUERY_SOCK_PATH);
124  		if (fd < 0) {
125  			rv = fd;
126  			goto out;
127  		}
128  	
129  		rv = do_write(fd, &h, sizeof(h));
130  		if (rv < 0)
131  			goto out_close;
132  	
133  		memset(&h, 0, sizeof(h));
134  	
135  		rv = do_read(fd, &h, sizeof(h));
136  		if (rv < 0)
137  			goto out_close;
138  	
139  		*data = h.data;
140  		len = h.len - sizeof(h);
141  	
142  		if (len <= 0 || len > DLMC_DUMP_SIZE)
143  			goto out_close;
144  	
145  		rv = do_read(fd, copy_buf, len);
146  		if (rv < 0)
147  			goto out_close;
148  	
149  		memcpy(buf, copy_buf, len);
150  	 out_close:
151  		close(fd);
152  	 out:
153  		return rv;
154  	}
155  	
156  	int dlmc_dump_debug(char *buf, int *data)
157  	{
158  		return do_dump(DLMC_CMD_DUMP_DEBUG, NULL, buf, data);
159  	}
160  	
161  	int dlmc_dump_config(char *buf, int *data)
162  	{
163  		return do_dump(DLMC_CMD_DUMP_CONFIG, NULL, buf, data);
164  	}
165  	
166  	int dlmc_dump_log_plock(char *buf, int *data)
167  	{
168  		return do_dump(DLMC_CMD_DUMP_LOG_PLOCK, NULL, buf, data);
169  	}
170  	
171  	int dlmc_dump_plocks(char *name, char *buf, int *data)
172  	{
173  		return do_dump(DLMC_CMD_DUMP_PLOCKS, name, buf, data);
174  	}
175  	
176  	int dlmc_dump_run(char *buf, int *data)
177  	{
178  		return do_dump(DLMC_CMD_DUMP_RUN, NULL, buf, data);
179  	}
180  	
181  	int dlmc_reload_config(void)
182  	{
183  		struct dlmc_header h;
184  		int fd, rv;
185  	
186  		init_header(&h, DLMC_CMD_RELOAD_CONFIG, NULL, 0);
187  	
188  		fd = do_connect(DLMC_SOCK_PATH);
189  		if (fd < 0) {
190  			rv = fd;
191  			goto out;
192  		}
193  	
194  		rv = do_write(fd, &h, sizeof(h));
195  		close(fd);
196  	out:
197  		return rv;
198  	}
199  	
200  	int dlmc_set_config(char *command)
201  	{
202  		struct dlmc_header h;
203  		char *cmdbuf;
204  		int fd, rv;
205  	
206  		cmdbuf = malloc(DLMC_RUN_COMMAND_LEN);
207  		if (!cmdbuf)
208  			return -1;
209  	
210  		memset(cmdbuf, 0, DLMC_RUN_COMMAND_LEN);
211  		strncpy(cmdbuf, command, DLMC_RUN_COMMAND_LEN-1);
212  	
213  		init_header(&h, DLMC_CMD_SET_CONFIG, NULL, DLMC_RUN_COMMAND_LEN);
214  	
215  		fd = do_connect(DLMC_SOCK_PATH);
216  		if (fd < 0) {
217  			rv = fd;
218  			goto out;
219  		}
220  	
221  		rv = do_write(fd, &h, sizeof(h));
222  		if (rv < 0)
223  			goto out_close;
224  	
225  		rv = do_write(fd, cmdbuf, DLMC_RUN_COMMAND_LEN);
226  		if (rv < 0)
227  			goto out_close;
228  	
229  	out_close:
230  		close(fd);
231  	out:
232  		free(cmdbuf);
233  		return rv;
234  	}
235  	
236  	static int nodeid_compare(const void *va, const void *vb)
237  	{
238  		const int *a = va;
239  		const int *b = vb;
240  	
241  		return *a - *b;
242  	}
243  	
244  	static void print_str(char *str, int len)
245  	{
246  		char *p;
247  		int i;
248  	
249  		p = &str[0];
250  		for (i = 0; i < len-1; i++) {
251  			if (str[i] == ' ') {
252  				str[i] = '\0';
253  				printf("    %s\n", p);
254  				p = &str[i+1];
255  			}
256  		}
257  	
258  		if (p)
259  			printf("    %s\n", p);
260  	}
261  	
262  	static unsigned int kv(char *str, const char *k)
263  	{
264  		char valstr[64];
265  		char *p;
266  		int i;
267  	
268  		p = strstr(str, k);
269  		if (!p)
270  			return 0;
271  	
272  		p = strstr(p, "=");
273  		if (!p)
274  			return 0;
275  	
276  		/* move pointer after '=' */
277  		p++;
278  	
279  		memset(valstr, 0, 64);
280  	
281  		for (i = 0; i < 64; i++) {
282  			if (*p == ' ')
283  				break;
284  			if (*p == '\0')
285  				break;
286  			if (*p == '\n')
287  				break;
288  			valstr[i] = *p;
289  			p++;
290  		}
291  	
292  		return (unsigned int)strtoul(valstr, NULL, 0);
293  	}
294  	
295  	static char *ks(char *str, const char *k)
296  	{
297  		static char valstr[64];
298  		char *p;
299  		int i;
300  	
301  		p = strstr(str, k);
302  		if (!p)
303  			return 0;
304  	
305  		p = strstr(p, "=");
306  		if (!p)
307  			return 0;
308  	
309  		/* move pointer after '=' */
310  		p++;
311  	
312  		memset(valstr, 0, 64);
313  	
314  		for (i = 0; i < 64; i++) {
315  			if (*p == ' ')
316  				break;
317  			if (*p == '\0')
318  				break;
319  			if (*p == '\n')
320  				break;
321  			valstr[i] = *p;
322  			p++;
323  		}
324  	
325  		return valstr;
326  	}
327  	
328  	static void print_daemon(struct dlmc_state *st, char *str, char *bin, uint32_t flags)
329  	{
330  		unsigned int cluster_ringid, daemon_ringid;
331  		unsigned int fipu;
332  	
333  		if (flags & DLMC_STATUS_VERBOSE) {
334  			printf("our_nodeid %d\n", st->nodeid);
335  			print_str(str, st->str_len);
336  			return;
337  		}
338  	
339  		cluster_ringid = kv(str, "cluster_ringid");
340  		daemon_ringid = kv(str, "daemon_ringid");
341  	
342  		printf("cluster nodeid %d quorate %u ring seq %u %u\n",
343  			st->nodeid,
344  			kv(str, "quorate"),
345  			cluster_ringid, daemon_ringid);
346  	
347  		fipu = kv(str, "fence_in_progress_unknown");
348  	
349  		printf("daemon now %u fence_pid %u %s\n",
350  			kv(str, "monotime"),
351  			kv(str, "fence_pid"),
352  			fipu ? "fence_init" : "");
353  	}
354  	
355  	static void format_daemon_node(struct dlmc_state *st, char *str, char *bin, uint32_t flags,
356  				       char *node_line, char *fence_line)
357  	{
358  		unsigned int delay_fencing, result_wait, killed;
359  		char letter;
360  	
361  		if (st->type == DLMC_STATE_STARTUP_NODE)
362  			letter = 'U';
363  		else if (kv(str, "member"))
364  			letter = 'M';
365  		else
366  			letter = 'X';
367  		
368  	
369  		snprintf(node_line, DLMC_STATE_MAXSTR - 1,
370  			"node %d %c add %u rem %u fail %u fence %u at %u %u\n",
371  			st->nodeid,
372  			letter,
373  			kv(str, "add_time"),
374  			kv(str, "rem_time"),
375  			kv(str, "fail_monotime"),
376  			kv(str, "fence_monotime"),
377  			kv(str, "actor_done"),
378  			kv(str, "fence_walltime"));
379  	
380  		if (!kv(str, "need_fencing"))
381  			return;
382  	
383  		delay_fencing = kv(str, "delay_fencing");
384  		result_wait = kv(str, "fence_result_wait");
385  		killed = kv(str, "killed");
386  	
387  		if (delay_fencing)
388  			snprintf(fence_line, DLMC_STATE_MAXSTR - 1,
389  				"fence %d %s delay actor %u fail %u fence %u now %u%s%s\n",
390  				st->nodeid,
391  				ks(str, "left_reason"),
392  				kv(str, "actor_last"),
393  				kv(str, "fail_walltime"),
394  				kv(str, "fence_walltime"),
395  				(unsigned int)time(NULL),
396  				result_wait ? " result_wait" : "",
397  				killed ? " killed" : "");
398  		else
399  			snprintf(fence_line, DLMC_STATE_MAXSTR - 1,
400  				"fence %d %s pid %d actor %u fail %u fence %u now %u%s%s\n",
401  				st->nodeid,
402  				ks(str, "left_reason"),
403  				kv(str, "fence_pid"),
404  				kv(str, "actor_last"),
405  				kv(str, "fail_walltime"),
406  				kv(str, "fence_walltime"),
407  				(unsigned int)time(NULL),
408  				result_wait ? " result_wait" : "",
409  				killed ? " killed" : "");
410  	}
411  	
412  	#define MAX_SORT 64
413  	
414  	int dlmc_print_status(uint32_t flags)
415  	{
416  		struct dlmc_header h;
417  		struct dlmc_state state;
418  		struct dlmc_state *st;
419  		char maxstr[DLMC_STATE_MAXSTR];
420  		char maxbin[DLMC_STATE_MAXBIN];
421  		char *str;
422  		char *bin;
423  		int all_count, node_count, fence_count, startup_count;
424  		int all_ids[MAX_SORT];
425  		int node_ids[MAX_SORT];
426  		int fence_ids[MAX_SORT];
427  		int startup_ids[MAX_SORT];
428  		char *node_lines[MAX_SORT];
429  		char *fence_lines[MAX_SORT];
430  		char *node_line;
431  		char *fence_line;
432  		int found_node;
433  		int fd, rv;
434  		int i, j;
435  	
436  		init_header(&h, DLMC_CMD_DUMP_STATUS, NULL, 0);
437  	
438  		fd = do_connect(DLMC_QUERY_SOCK_PATH);
(1) Event cond_false: Condition "fd < 0", taking false branch.
439  		if (fd < 0) {
440  			printf("cannot connect to dlm_controld\n");
441  			rv = fd;
442  			goto out;
(2) Event if_end: End of if statement.
443  		}
444  	
445  		rv = do_write(fd, &h, sizeof(h));
(3) Event cond_false: Condition "rv < 0", taking false branch.
446  		if (rv < 0) {
447  			printf("cannot send to dlm_controld\n");
448  			goto out_close;
(4) Event if_end: End of if statement.
449  		}
450  	
451  		st = &state;
452  		str = maxstr;
453  		bin = maxbin;
454  	
455  		all_count = 0;
456  		node_count = 0;
457  		fence_count = 0;
458  		startup_count = 0;
459  		memset(&all_ids, 0, sizeof(all_ids));
460  		memset(&node_ids, 0, sizeof(node_ids));
461  		memset(&fence_ids, 0, sizeof(fence_ids));
462  		memset(&startup_ids, 0, sizeof(startup_ids));
463  		memset(node_lines, 0, sizeof(node_lines));
464  		memset(fence_lines, 0, sizeof(fence_lines));
465  	
(22) Event loop_begin: Jumped back to beginning of loop.
(40) Event loop_begin: Jumped back to beginning of loop.
(58) Event loop_begin: Jumped back to beginning of loop.
(76) Event loop_begin: Jumped back to beginning of loop.
(94) Event loop_begin: Jumped back to beginning of loop.
(112) Event loop_begin: Jumped back to beginning of loop.
(130) Event loop_begin: Jumped back to beginning of loop.
(148) Event loop_begin: Jumped back to beginning of loop.
(166) Event loop_begin: Jumped back to beginning of loop.
(184) Event loop_begin: Jumped back to beginning of loop.
(202) Event loop_begin: Jumped back to beginning of loop.
(220) Event loop_begin: Jumped back to beginning of loop.
(238) Event loop_begin: Jumped back to beginning of loop.
(256) Event loop_begin: Jumped back to beginning of loop.
(274) Event loop_begin: Jumped back to beginning of loop.
(292) Event loop_begin: Jumped back to beginning of loop.
(310) Event loop_begin: Jumped back to beginning of loop.
(328) Event loop_begin: Jumped back to beginning of loop.
(346) Event loop_begin: Jumped back to beginning of loop.
(364) Event loop_begin: Jumped back to beginning of loop.
(382) Event loop_begin: Jumped back to beginning of loop.
(400) Event loop_begin: Jumped back to beginning of loop.
(418) Event loop_begin: Jumped back to beginning of loop.
(436) Event loop_begin: Jumped back to beginning of loop.
(454) Event loop_begin: Jumped back to beginning of loop.
(472) Event loop_begin: Jumped back to beginning of loop.
(490) Event loop_begin: Jumped back to beginning of loop.
(508) Event loop_begin: Jumped back to beginning of loop.
(526) Event loop_begin: Jumped back to beginning of loop.
(544) Event loop_begin: Jumped back to beginning of loop.
(562) Event loop_begin: Jumped back to beginning of loop.
(580) Event loop_begin: Jumped back to beginning of loop.
466  		while (1) {
467  			memset(&state, 0, sizeof(state));
468  			memset(maxstr, 0, sizeof(maxstr));
469  			memset(maxbin, 0, sizeof(maxbin));
470  	
(581) Event tainted_data_argument: The value "*st" is considered tainted.
Also see events: [tainted_data_argument][underflow]
471  			rv = recv(fd, st, sizeof(struct dlmc_state), MSG_WAITALL);
(5) Event cond_false: Condition "!rv", taking false branch.
(23) Event cond_false: Condition "!rv", taking false branch.
(41) Event cond_false: Condition "!rv", taking false branch.
(59) Event cond_false: Condition "!rv", taking false branch.
(77) Event cond_false: Condition "!rv", taking false branch.
(95) Event cond_false: Condition "!rv", taking false branch.
(113) Event cond_false: Condition "!rv", taking false branch.
(131) Event cond_false: Condition "!rv", taking false branch.
(149) Event cond_false: Condition "!rv", taking false branch.
(167) Event cond_false: Condition "!rv", taking false branch.
(185) Event cond_false: Condition "!rv", taking false branch.
(203) Event cond_false: Condition "!rv", taking false branch.
(221) Event cond_false: Condition "!rv", taking false branch.
(239) Event cond_false: Condition "!rv", taking false branch.
(257) Event cond_false: Condition "!rv", taking false branch.
(275) Event cond_false: Condition "!rv", taking false branch.
(293) Event cond_false: Condition "!rv", taking false branch.
(311) Event cond_false: Condition "!rv", taking false branch.
(329) Event cond_false: Condition "!rv", taking false branch.
(347) Event cond_false: Condition "!rv", taking false branch.
(365) Event cond_false: Condition "!rv", taking false branch.
(383) Event cond_false: Condition "!rv", taking false branch.
(401) Event cond_false: Condition "!rv", taking false branch.
(419) Event cond_false: Condition "!rv", taking false branch.
(437) Event cond_false: Condition "!rv", taking false branch.
(455) Event cond_false: Condition "!rv", taking false branch.
(473) Event cond_false: Condition "!rv", taking false branch.
(491) Event cond_false: Condition "!rv", taking false branch.
(509) Event cond_false: Condition "!rv", taking false branch.
(527) Event cond_false: Condition "!rv", taking false branch.
(545) Event cond_false: Condition "!rv", taking false branch.
(563) Event cond_false: Condition "!rv", taking false branch.
(582) Event cond_false: Condition "!rv", taking false branch.
472  			if (!rv)
(6) Event if_end: End of if statement.
(24) Event if_end: End of if statement.
(42) Event if_end: End of if statement.
(60) Event if_end: End of if statement.
(78) Event if_end: End of if statement.
(96) Event if_end: End of if statement.
(114) Event if_end: End of if statement.
(132) Event if_end: End of if statement.
(150) Event if_end: End of if statement.
(168) Event if_end: End of if statement.
(186) Event if_end: End of if statement.
(204) Event if_end: End of if statement.
(222) Event if_end: End of if statement.
(240) Event if_end: End of if statement.
(258) Event if_end: End of if statement.
(276) Event if_end: End of if statement.
(294) Event if_end: End of if statement.
(312) Event if_end: End of if statement.
(330) Event if_end: End of if statement.
(348) Event if_end: End of if statement.
(366) Event if_end: End of if statement.
(384) Event if_end: End of if statement.
(402) Event if_end: End of if statement.
(420) Event if_end: End of if statement.
(438) Event if_end: End of if statement.
(456) Event if_end: End of if statement.
(474) Event if_end: End of if statement.
(492) Event if_end: End of if statement.
(510) Event if_end: End of if statement.
(528) Event if_end: End of if statement.
(546) Event if_end: End of if statement.
(564) Event if_end: End of if statement.
(583) Event if_end: End of if statement.
473  				break;
(7) Event cond_false: Condition "rv != 28UL /* sizeof (struct dlmc_state) */", taking false branch.
(25) Event cond_false: Condition "rv != 28UL /* sizeof (struct dlmc_state) */", taking false branch.
(43) Event cond_false: Condition "rv != 28UL /* sizeof (struct dlmc_state) */", taking false branch.
(61) Event cond_false: Condition "rv != 28UL /* sizeof (struct dlmc_state) */", taking false branch.
(79) Event cond_false: Condition "rv != 28UL /* sizeof (struct dlmc_state) */", taking false branch.
(97) Event cond_false: Condition "rv != 28UL /* sizeof (struct dlmc_state) */", taking false branch.
(115) Event cond_false: Condition "rv != 28UL /* sizeof (struct dlmc_state) */", taking false branch.
(133) Event cond_false: Condition "rv != 28UL /* sizeof (struct dlmc_state) */", taking false branch.
(151) Event cond_false: Condition "rv != 28UL /* sizeof (struct dlmc_state) */", taking false branch.
(169) Event cond_false: Condition "rv != 28UL /* sizeof (struct dlmc_state) */", taking false branch.
(187) Event cond_false: Condition "rv != 28UL /* sizeof (struct dlmc_state) */", taking false branch.
(205) Event cond_false: Condition "rv != 28UL /* sizeof (struct dlmc_state) */", taking false branch.
(223) Event cond_false: Condition "rv != 28UL /* sizeof (struct dlmc_state) */", taking false branch.
(241) Event cond_false: Condition "rv != 28UL /* sizeof (struct dlmc_state) */", taking false branch.
(259) Event cond_false: Condition "rv != 28UL /* sizeof (struct dlmc_state) */", taking false branch.
(277) Event cond_false: Condition "rv != 28UL /* sizeof (struct dlmc_state) */", taking false branch.
(295) Event cond_false: Condition "rv != 28UL /* sizeof (struct dlmc_state) */", taking false branch.
(313) Event cond_false: Condition "rv != 28UL /* sizeof (struct dlmc_state) */", taking false branch.
(331) Event cond_false: Condition "rv != 28UL /* sizeof (struct dlmc_state) */", taking false branch.
(349) Event cond_false: Condition "rv != 28UL /* sizeof (struct dlmc_state) */", taking false branch.
(367) Event cond_false: Condition "rv != 28UL /* sizeof (struct dlmc_state) */", taking false branch.
(385) Event cond_false: Condition "rv != 28UL /* sizeof (struct dlmc_state) */", taking false branch.
(403) Event cond_false: Condition "rv != 28UL /* sizeof (struct dlmc_state) */", taking false branch.
(421) Event cond_false: Condition "rv != 28UL /* sizeof (struct dlmc_state) */", taking false branch.
(439) Event cond_false: Condition "rv != 28UL /* sizeof (struct dlmc_state) */", taking false branch.
(457) Event cond_false: Condition "rv != 28UL /* sizeof (struct dlmc_state) */", taking false branch.
(475) Event cond_false: Condition "rv != 28UL /* sizeof (struct dlmc_state) */", taking false branch.
(493) Event cond_false: Condition "rv != 28UL /* sizeof (struct dlmc_state) */", taking false branch.
(511) Event cond_false: Condition "rv != 28UL /* sizeof (struct dlmc_state) */", taking false branch.
(529) Event cond_false: Condition "rv != 28UL /* sizeof (struct dlmc_state) */", taking false branch.
(547) Event cond_false: Condition "rv != 28UL /* sizeof (struct dlmc_state) */", taking false branch.
(565) Event cond_false: Condition "rv != 28UL /* sizeof (struct dlmc_state) */", taking false branch.
(584) Event cond_false: Condition "rv != 28UL /* sizeof (struct dlmc_state) */", taking false branch.
474  			if (rv != sizeof(struct dlmc_state))
(8) Event if_end: End of if statement.
(26) Event if_end: End of if statement.
(44) Event if_end: End of if statement.
(62) Event if_end: End of if statement.
(80) Event if_end: End of if statement.
(98) Event if_end: End of if statement.
(116) Event if_end: End of if statement.
(134) Event if_end: End of if statement.
(152) Event if_end: End of if statement.
(170) Event if_end: End of if statement.
(188) Event if_end: End of if statement.
(206) Event if_end: End of if statement.
(224) Event if_end: End of if statement.
(242) Event if_end: End of if statement.
(260) Event if_end: End of if statement.
(278) Event if_end: End of if statement.
(296) Event if_end: End of if statement.
(314) Event if_end: End of if statement.
(332) Event if_end: End of if statement.
(350) Event if_end: End of if statement.
(368) Event if_end: End of if statement.
(386) Event if_end: End of if statement.
(404) Event if_end: End of if statement.
(422) Event if_end: End of if statement.
(440) Event if_end: End of if statement.
(458) Event if_end: End of if statement.
(476) Event if_end: End of if statement.
(494) Event if_end: End of if statement.
(512) Event if_end: End of if statement.
(530) Event if_end: End of if statement.
(548) Event if_end: End of if statement.
(566) Event if_end: End of if statement.
(585) Event if_end: End of if statement.
475  				break;
476  	
(9) Event cond_true: Condition "st->str_len", taking true branch.
(27) Event cond_true: Condition "st->str_len", taking true branch.
(45) Event cond_true: Condition "st->str_len", taking true branch.
(63) Event cond_true: Condition "st->str_len", taking true branch.
(81) Event cond_true: Condition "st->str_len", taking true branch.
(99) Event cond_true: Condition "st->str_len", taking true branch.
(117) Event cond_true: Condition "st->str_len", taking true branch.
(135) Event cond_true: Condition "st->str_len", taking true branch.
(153) Event cond_true: Condition "st->str_len", taking true branch.
(171) Event cond_true: Condition "st->str_len", taking true branch.
(189) Event cond_true: Condition "st->str_len", taking true branch.
(207) Event cond_true: Condition "st->str_len", taking true branch.
(225) Event cond_true: Condition "st->str_len", taking true branch.
(243) Event cond_true: Condition "st->str_len", taking true branch.
(261) Event cond_true: Condition "st->str_len", taking true branch.
(279) Event cond_true: Condition "st->str_len", taking true branch.
(297) Event cond_true: Condition "st->str_len", taking true branch.
(315) Event cond_true: Condition "st->str_len", taking true branch.
(333) Event cond_true: Condition "st->str_len", taking true branch.
(351) Event cond_true: Condition "st->str_len", taking true branch.
(369) Event cond_true: Condition "st->str_len", taking true branch.
(387) Event cond_true: Condition "st->str_len", taking true branch.
(405) Event cond_true: Condition "st->str_len", taking true branch.
(423) Event cond_true: Condition "st->str_len", taking true branch.
(441) Event cond_true: Condition "st->str_len", taking true branch.
(459) Event cond_true: Condition "st->str_len", taking true branch.
(477) Event cond_true: Condition "st->str_len", taking true branch.
(495) Event cond_true: Condition "st->str_len", taking true branch.
(513) Event cond_true: Condition "st->str_len", taking true branch.
(531) Event cond_true: Condition "st->str_len", taking true branch.
(549) Event cond_true: Condition "st->str_len", taking true branch.
(567) Event cond_true: Condition "st->str_len", taking true branch.
(586) Event tainted_data_argument: "st->str_len" is considered tainted.
(587) Event cond_true: Condition "st->str_len", taking true branch.
Also see events: [tainted_data_argument][underflow]
477  			if (st->str_len) {
478  				rv = recv(fd, str, st->str_len, MSG_WAITALL);
(10) Event cond_false: Condition "rv != st->str_len", taking false branch.
(28) Event cond_false: Condition "rv != st->str_len", taking false branch.
(46) Event cond_false: Condition "rv != st->str_len", taking false branch.
(64) Event cond_false: Condition "rv != st->str_len", taking false branch.
(82) Event cond_false: Condition "rv != st->str_len", taking false branch.
(100) Event cond_false: Condition "rv != st->str_len", taking false branch.
(118) Event cond_false: Condition "rv != st->str_len", taking false branch.
(136) Event cond_false: Condition "rv != st->str_len", taking false branch.
(154) Event cond_false: Condition "rv != st->str_len", taking false branch.
(172) Event cond_false: Condition "rv != st->str_len", taking false branch.
(190) Event cond_false: Condition "rv != st->str_len", taking false branch.
(208) Event cond_false: Condition "rv != st->str_len", taking false branch.
(226) Event cond_false: Condition "rv != st->str_len", taking false branch.
(244) Event cond_false: Condition "rv != st->str_len", taking false branch.
(262) Event cond_false: Condition "rv != st->str_len", taking false branch.
(280) Event cond_false: Condition "rv != st->str_len", taking false branch.
(298) Event cond_false: Condition "rv != st->str_len", taking false branch.
(316) Event cond_false: Condition "rv != st->str_len", taking false branch.
(334) Event cond_false: Condition "rv != st->str_len", taking false branch.
(352) Event cond_false: Condition "rv != st->str_len", taking false branch.
(370) Event cond_false: Condition "rv != st->str_len", taking false branch.
(388) Event cond_false: Condition "rv != st->str_len", taking false branch.
(406) Event cond_false: Condition "rv != st->str_len", taking false branch.
(424) Event cond_false: Condition "rv != st->str_len", taking false branch.
(442) Event cond_false: Condition "rv != st->str_len", taking false branch.
(460) Event cond_false: Condition "rv != st->str_len", taking false branch.
(478) Event cond_false: Condition "rv != st->str_len", taking false branch.
(496) Event cond_false: Condition "rv != st->str_len", taking false branch.
(514) Event cond_false: Condition "rv != st->str_len", taking false branch.
(532) Event cond_false: Condition "rv != st->str_len", taking false branch.
(550) Event cond_false: Condition "rv != st->str_len", taking false branch.
(568) Event cond_false: Condition "rv != st->str_len", taking false branch.
(588) Event cond_false: Condition "rv != st->str_len", taking false branch.
479  				if (rv != st->str_len)
(11) Event if_end: End of if statement.
(29) Event if_end: End of if statement.
(47) Event if_end: End of if statement.
(65) Event if_end: End of if statement.
(83) Event if_end: End of if statement.
(101) Event if_end: End of if statement.
(119) Event if_end: End of if statement.
(137) Event if_end: End of if statement.
(155) Event if_end: End of if statement.
(173) Event if_end: End of if statement.
(191) Event if_end: End of if statement.
(209) Event if_end: End of if statement.
(227) Event if_end: End of if statement.
(245) Event if_end: End of if statement.
(263) Event if_end: End of if statement.
(281) Event if_end: End of if statement.
(299) Event if_end: End of if statement.
(317) Event if_end: End of if statement.
(335) Event if_end: End of if statement.
(353) Event if_end: End of if statement.
(371) Event if_end: End of if statement.
(389) Event if_end: End of if statement.
(407) Event if_end: End of if statement.
(425) Event if_end: End of if statement.
(443) Event if_end: End of if statement.
(461) Event if_end: End of if statement.
(479) Event if_end: End of if statement.
(497) Event if_end: End of if statement.
(515) Event if_end: End of if statement.
(533) Event if_end: End of if statement.
(551) Event if_end: End of if statement.
(569) Event if_end: End of if statement.
(589) Event if_end: End of if statement.
480  					break;
481  			}
482  	
(12) Event cond_true: Condition "st->bin_len", taking true branch.
(30) Event cond_true: Condition "st->bin_len", taking true branch.
(48) Event cond_true: Condition "st->bin_len", taking true branch.
(66) Event cond_true: Condition "st->bin_len", taking true branch.
(84) Event cond_true: Condition "st->bin_len", taking true branch.
(102) Event cond_true: Condition "st->bin_len", taking true branch.
(120) Event cond_true: Condition "st->bin_len", taking true branch.
(138) Event cond_true: Condition "st->bin_len", taking true branch.
(156) Event cond_true: Condition "st->bin_len", taking true branch.
(174) Event cond_true: Condition "st->bin_len", taking true branch.
(192) Event cond_true: Condition "st->bin_len", taking true branch.
(210) Event cond_true: Condition "st->bin_len", taking true branch.
(228) Event cond_true: Condition "st->bin_len", taking true branch.
(246) Event cond_true: Condition "st->bin_len", taking true branch.
(264) Event cond_true: Condition "st->bin_len", taking true branch.
(282) Event cond_true: Condition "st->bin_len", taking true branch.
(300) Event cond_true: Condition "st->bin_len", taking true branch.
(318) Event cond_true: Condition "st->bin_len", taking true branch.
(336) Event cond_true: Condition "st->bin_len", taking true branch.
(354) Event cond_true: Condition "st->bin_len", taking true branch.
(372) Event cond_true: Condition "st->bin_len", taking true branch.
(390) Event cond_true: Condition "st->bin_len", taking true branch.
(408) Event cond_true: Condition "st->bin_len", taking true branch.
(426) Event cond_true: Condition "st->bin_len", taking true branch.
(444) Event cond_true: Condition "st->bin_len", taking true branch.
(462) Event cond_true: Condition "st->bin_len", taking true branch.
(480) Event cond_true: Condition "st->bin_len", taking true branch.
(498) Event cond_true: Condition "st->bin_len", taking true branch.
(516) Event cond_true: Condition "st->bin_len", taking true branch.
(534) Event cond_true: Condition "st->bin_len", taking true branch.
(552) Event cond_true: Condition "st->bin_len", taking true branch.
(570) Event cond_true: Condition "st->bin_len", taking true branch.
(590) Event cond_true: Condition "st->bin_len", taking true branch.
483  			if (st->bin_len) {
484  				rv = recv(fd, bin, st->bin_len, MSG_WAITALL);
(13) Event cond_false: Condition "rv != st->bin_len", taking false branch.
(31) Event cond_false: Condition "rv != st->bin_len", taking false branch.
(49) Event cond_false: Condition "rv != st->bin_len", taking false branch.
(67) Event cond_false: Condition "rv != st->bin_len", taking false branch.
(85) Event cond_false: Condition "rv != st->bin_len", taking false branch.
(103) Event cond_false: Condition "rv != st->bin_len", taking false branch.
(121) Event cond_false: Condition "rv != st->bin_len", taking false branch.
(139) Event cond_false: Condition "rv != st->bin_len", taking false branch.
(157) Event cond_false: Condition "rv != st->bin_len", taking false branch.
(175) Event cond_false: Condition "rv != st->bin_len", taking false branch.
(193) Event cond_false: Condition "rv != st->bin_len", taking false branch.
(211) Event cond_false: Condition "rv != st->bin_len", taking false branch.
(229) Event cond_false: Condition "rv != st->bin_len", taking false branch.
(247) Event cond_false: Condition "rv != st->bin_len", taking false branch.
(265) Event cond_false: Condition "rv != st->bin_len", taking false branch.
(283) Event cond_false: Condition "rv != st->bin_len", taking false branch.
(301) Event cond_false: Condition "rv != st->bin_len", taking false branch.
(319) Event cond_false: Condition "rv != st->bin_len", taking false branch.
(337) Event cond_false: Condition "rv != st->bin_len", taking false branch.
(355) Event cond_false: Condition "rv != st->bin_len", taking false branch.
(373) Event cond_false: Condition "rv != st->bin_len", taking false branch.
(391) Event cond_false: Condition "rv != st->bin_len", taking false branch.
(409) Event cond_false: Condition "rv != st->bin_len", taking false branch.
(427) Event cond_false: Condition "rv != st->bin_len", taking false branch.
(445) Event cond_false: Condition "rv != st->bin_len", taking false branch.
(463) Event cond_false: Condition "rv != st->bin_len", taking false branch.
(481) Event cond_false: Condition "rv != st->bin_len", taking false branch.
(499) Event cond_false: Condition "rv != st->bin_len", taking false branch.
(517) Event cond_false: Condition "rv != st->bin_len", taking false branch.
(535) Event cond_false: Condition "rv != st->bin_len", taking false branch.
(553) Event cond_false: Condition "rv != st->bin_len", taking false branch.
(571) Event cond_false: Condition "rv != st->bin_len", taking false branch.
(591) Event cond_false: Condition "rv != st->bin_len", taking false branch.
485  				if (rv != st->bin_len)
(14) Event if_end: End of if statement.
(32) Event if_end: End of if statement.
(50) Event if_end: End of if statement.
(68) Event if_end: End of if statement.
(86) Event if_end: End of if statement.
(104) Event if_end: End of if statement.
(122) Event if_end: End of if statement.
(140) Event if_end: End of if statement.
(158) Event if_end: End of if statement.
(176) Event if_end: End of if statement.
(194) Event if_end: End of if statement.
(212) Event if_end: End of if statement.
(230) Event if_end: End of if statement.
(248) Event if_end: End of if statement.
(266) Event if_end: End of if statement.
(284) Event if_end: End of if statement.
(302) Event if_end: End of if statement.
(320) Event if_end: End of if statement.
(338) Event if_end: End of if statement.
(356) Event if_end: End of if statement.
(374) Event if_end: End of if statement.
(392) Event if_end: End of if statement.
(410) Event if_end: End of if statement.
(428) Event if_end: End of if statement.
(446) Event if_end: End of if statement.
(464) Event if_end: End of if statement.
(482) Event if_end: End of if statement.
(500) Event if_end: End of if statement.
(518) Event if_end: End of if statement.
(536) Event if_end: End of if statement.
(554) Event if_end: End of if statement.
(572) Event if_end: End of if statement.
(592) Event if_end: End of if statement.
486  					break;
487  			}
488  	
(15) Event switch: Switch case value "1".
(33) Event switch: Switch case value "3".
(51) Event switch: Switch case value "3".
(69) Event switch: Switch case value "3".
(87) Event switch: Switch case value "3".
(105) Event switch: Switch case value "3".
(123) Event switch: Switch case value "3".
(141) Event switch: Switch case value "3".
(159) Event switch: Switch case value "3".
(177) Event switch: Switch case value "3".
(195) Event switch: Switch case value "3".
(213) Event switch: Switch case value "3".
(231) Event switch: Switch case value "3".
(249) Event switch: Switch case value "3".
(267) Event switch: Switch case value "3".
(285) Event switch: Switch case value "3".
(303) Event switch: Switch case value "3".
(321) Event switch: Switch case value "3".
(339) Event switch: Switch case value "3".
(357) Event switch: Switch case value "3".
(375) Event switch: Switch case value "3".
(393) Event switch: Switch case value "3".
(411) Event switch: Switch case value "3".
(429) Event switch: Switch case value "3".
(447) Event switch: Switch case value "3".
(465) Event switch: Switch case value "3".
(483) Event switch: Switch case value "3".
(501) Event switch: Switch case value "3".
(519) Event switch: Switch case value "3".
(537) Event switch: Switch case value "3".
(555) Event switch: Switch case value "3".
(573) Event switch: Switch case value "3".
(593) Event switch: Switch case value "2".
489  			switch (st->type) {
(16) Event switch_case: Reached case "1".
490  			case DLMC_STATE_DAEMON:
491  				print_daemon(st, str, bin, flags);
(17) Event break: Breaking from switch.
492  				break;
493  	
(34) Event switch_case: Reached case "3".
(52) Event switch_case: Reached case "3".
(70) Event switch_case: Reached case "3".
(88) Event switch_case: Reached case "3".
(106) Event switch_case: Reached case "3".
(124) Event switch_case: Reached case "3".
(142) Event switch_case: Reached case "3".
(160) Event switch_case: Reached case "3".
(178) Event switch_case: Reached case "3".
(196) Event switch_case: Reached case "3".
(214) Event switch_case: Reached case "3".
(232) Event switch_case: Reached case "3".
(250) Event switch_case: Reached case "3".
(268) Event switch_case: Reached case "3".
(286) Event switch_case: Reached case "3".
(304) Event switch_case: Reached case "3".
(322) Event switch_case: Reached case "3".
(340) Event switch_case: Reached case "3".
(358) Event switch_case: Reached case "3".
(376) Event switch_case: Reached case "3".
(394) Event switch_case: Reached case "3".
(412) Event switch_case: Reached case "3".
(430) Event switch_case: Reached case "3".
(448) Event switch_case: Reached case "3".
(466) Event switch_case: Reached case "3".
(484) Event switch_case: Reached case "3".
(502) Event switch_case: Reached case "3".
(520) Event switch_case: Reached case "3".
(538) Event switch_case: Reached case "3".
(556) Event switch_case: Reached case "3".
(574) Event switch_case: Reached case "3".
494  			case DLMC_STATE_STARTUP_NODE:
495  				startup_ids[startup_count++] = st->nodeid;
(35) Event break: Breaking from switch.
(53) Event break: Breaking from switch.
(71) Event break: Breaking from switch.
(89) Event break: Breaking from switch.
(107) Event break: Breaking from switch.
(125) Event break: Breaking from switch.
(143) Event break: Breaking from switch.
(161) Event break: Breaking from switch.
(179) Event break: Breaking from switch.
(197) Event break: Breaking from switch.
(215) Event break: Breaking from switch.
(233) Event break: Breaking from switch.
(251) Event break: Breaking from switch.
(269) Event break: Breaking from switch.
(287) Event break: Breaking from switch.
(305) Event break: Breaking from switch.
(323) Event break: Breaking from switch.
(341) Event break: Breaking from switch.
(359) Event break: Breaking from switch.
(377) Event break: Breaking from switch.
(395) Event break: Breaking from switch.
(413) Event break: Breaking from switch.
(431) Event break: Breaking from switch.
(449) Event break: Breaking from switch.
(467) Event break: Breaking from switch.
(485) Event break: Breaking from switch.
(503) Event break: Breaking from switch.
(521) Event break: Breaking from switch.
(539) Event break: Breaking from switch.
(557) Event break: Breaking from switch.
(575) Event break: Breaking from switch.
496  				break;
497  	
(594) Event switch_case: Reached case "2".
498  			case DLMC_STATE_DAEMON_NODE:
(595) Event cond_true: Condition "flags & 1", taking true branch.
499  				if (flags & DLMC_STATUS_VERBOSE) {
500  					printf("nodeid %d\n", st->nodeid);
(596) Event underflow: The cast of "st->str_len" to a signed type could result in a negative number.
Also see events: [tainted_data_argument][tainted_data_argument]
501  					print_str(str, st->str_len);
502  				} else {
503  					node_line = malloc(DLMC_STATE_MAXSTR);
504  					if (!node_line)
505  						break;
506  					fence_line = malloc(DLMC_STATE_MAXSTR);
507  					if (!fence_line) {
508  						free(node_line);
509  						break;
510  					}
511  					memset(node_line, 0, DLMC_STATE_MAXSTR);
512  					memset(fence_line, 0, DLMC_STATE_MAXSTR);
513  	
514  					format_daemon_node(st, str, bin, flags,
515  							   node_line, fence_line);
516  	
517  					all_ids[all_count++] = st->nodeid;
518  	
519  					node_ids[node_count] = st->nodeid;
520  					node_lines[node_count] = node_line;
521  					node_count++;
522  	
523  					if (!fence_line[0]) {
524  						free(fence_line);
525  					} else {
526  						fence_ids[fence_count] = st->nodeid;
527  						fence_lines[fence_count] = fence_line;
528  						fence_count++;
529  					}
530  				}
531  				break;
532  	
533  			default:
534  				break;
(18) Event switch_end: Reached end of switch.
(36) Event switch_end: Reached end of switch.
(54) Event switch_end: Reached end of switch.
(72) Event switch_end: Reached end of switch.
(90) Event switch_end: Reached end of switch.
(108) Event switch_end: Reached end of switch.
(126) Event switch_end: Reached end of switch.
(144) Event switch_end: Reached end of switch.
(162) Event switch_end: Reached end of switch.
(180) Event switch_end: Reached end of switch.
(198) Event switch_end: Reached end of switch.
(216) Event switch_end: Reached end of switch.
(234) Event switch_end: Reached end of switch.
(252) Event switch_end: Reached end of switch.
(270) Event switch_end: Reached end of switch.
(288) Event switch_end: Reached end of switch.
(306) Event switch_end: Reached end of switch.
(324) Event switch_end: Reached end of switch.
(342) Event switch_end: Reached end of switch.
(360) Event switch_end: Reached end of switch.
(378) Event switch_end: Reached end of switch.
(396) Event switch_end: Reached end of switch.
(414) Event switch_end: Reached end of switch.
(432) Event switch_end: Reached end of switch.
(450) Event switch_end: Reached end of switch.
(468) Event switch_end: Reached end of switch.
(486) Event switch_end: Reached end of switch.
(504) Event switch_end: Reached end of switch.
(522) Event switch_end: Reached end of switch.
(540) Event switch_end: Reached end of switch.
(558) Event switch_end: Reached end of switch.
(576) Event switch_end: Reached end of switch.
535  			}
536  	
(19) Event cond_false: Condition "rv < 0", taking false branch.
(37) Event cond_false: Condition "rv < 0", taking false branch.
(55) Event cond_false: Condition "rv < 0", taking false branch.
(73) Event cond_false: Condition "rv < 0", taking false branch.
(91) Event cond_false: Condition "rv < 0", taking false branch.
(109) Event cond_false: Condition "rv < 0", taking false branch.
(127) Event cond_false: Condition "rv < 0", taking false branch.
(145) Event cond_false: Condition "rv < 0", taking false branch.
(163) Event cond_false: Condition "rv < 0", taking false branch.
(181) Event cond_false: Condition "rv < 0", taking false branch.
(199) Event cond_false: Condition "rv < 0", taking false branch.
(217) Event cond_false: Condition "rv < 0", taking false branch.
(235) Event cond_false: Condition "rv < 0", taking false branch.
(253) Event cond_false: Condition "rv < 0", taking false branch.
(271) Event cond_false: Condition "rv < 0", taking false branch.
(289) Event cond_false: Condition "rv < 0", taking false branch.
(307) Event cond_false: Condition "rv < 0", taking false branch.
(325) Event cond_false: Condition "rv < 0", taking false branch.
(343) Event cond_false: Condition "rv < 0", taking false branch.
(361) Event cond_false: Condition "rv < 0", taking false branch.
(379) Event cond_false: Condition "rv < 0", taking false branch.
(397) Event cond_false: Condition "rv < 0", taking false branch.
(415) Event cond_false: Condition "rv < 0", taking false branch.
(433) Event cond_false: Condition "rv < 0", taking false branch.
(451) Event cond_false: Condition "rv < 0", taking false branch.
(469) Event cond_false: Condition "rv < 0", taking false branch.
(487) Event cond_false: Condition "rv < 0", taking false branch.
(505) Event cond_false: Condition "rv < 0", taking false branch.
(523) Event cond_false: Condition "rv < 0", taking false branch.
(541) Event cond_false: Condition "rv < 0", taking false branch.
(559) Event cond_false: Condition "rv < 0", taking false branch.
(577) Event cond_false: Condition "rv < 0", taking false branch.
537  			if (rv < 0)
(20) Event if_end: End of if statement.
(38) Event if_end: End of if statement.
(56) Event if_end: End of if statement.
(74) Event if_end: End of if statement.
(92) Event if_end: End of if statement.
(110) Event if_end: End of if statement.
(128) Event if_end: End of if statement.
(146) Event if_end: End of if statement.
(164) Event if_end: End of if statement.
(182) Event if_end: End of if statement.
(200) Event if_end: End of if statement.
(218) Event if_end: End of if statement.
(236) Event if_end: End of if statement.
(254) Event if_end: End of if statement.
(272) Event if_end: End of if statement.
(290) Event if_end: End of if statement.
(308) Event if_end: End of if statement.
(326) Event if_end: End of if statement.
(344) Event if_end: End of if statement.
(362) Event if_end: End of if statement.
(380) Event if_end: End of if statement.
(398) Event if_end: End of if statement.
(416) Event if_end: End of if statement.
(434) Event if_end: End of if statement.
(452) Event if_end: End of if statement.
(470) Event if_end: End of if statement.
(488) Event if_end: End of if statement.
(506) Event if_end: End of if statement.
(524) Event if_end: End of if statement.
(542) Event if_end: End of if statement.
(560) Event if_end: End of if statement.
(578) Event if_end: End of if statement.
538  				break;
(21) Event loop: Jumping back to the beginning of the loop.
(39) Event loop: Jumping back to the beginning of the loop.
(57) Event loop: Jumping back to the beginning of the loop.
(75) Event loop: Jumping back to the beginning of the loop.
(93) Event loop: Jumping back to the beginning of the loop.
(111) Event loop: Jumping back to the beginning of the loop.
(129) Event loop: Jumping back to the beginning of the loop.
(147) Event loop: Jumping back to the beginning of the loop.
(165) Event loop: Jumping back to the beginning of the loop.
(183) Event loop: Jumping back to the beginning of the loop.
(201) Event loop: Jumping back to the beginning of the loop.
(219) Event loop: Jumping back to the beginning of the loop.
(237) Event loop: Jumping back to the beginning of the loop.
(255) Event loop: Jumping back to the beginning of the loop.
(273) Event loop: Jumping back to the beginning of the loop.
(291) Event loop: Jumping back to the beginning of the loop.
(309) Event loop: Jumping back to the beginning of the loop.
(327) Event loop: Jumping back to the beginning of the loop.
(345) Event loop: Jumping back to the beginning of the loop.
(363) Event loop: Jumping back to the beginning of the loop.
(381) Event loop: Jumping back to the beginning of the loop.
(399) Event loop: Jumping back to the beginning of the loop.
(417) Event loop: Jumping back to the beginning of the loop.
(435) Event loop: Jumping back to the beginning of the loop.
(453) Event loop: Jumping back to the beginning of the loop.
(471) Event loop: Jumping back to the beginning of the loop.
(489) Event loop: Jumping back to the beginning of the loop.
(507) Event loop: Jumping back to the beginning of the loop.
(525) Event loop: Jumping back to the beginning of the loop.
(543) Event loop: Jumping back to the beginning of the loop.
(561) Event loop: Jumping back to the beginning of the loop.
(579) Event loop: Jumping back to the beginning of the loop.
539  		}
540  	
541  		if (all_count)
542  			qsort(all_ids, all_count, sizeof(int), nodeid_compare);
543  	
544  		/* don't free any node_lines in this startup loop because we are just
545  		   borrowing them; they are needed in the real node loop below. */
546  	
547  		if (startup_count) {
548  			for (i = 0; i < startup_count; i++) {
549  				found_node = 0;
550  				for (j = 0; j < node_count; j++) {
551  					if (startup_ids[i] != node_ids[j])
552  						continue;
553  					found_node = 1;
554  					if (!node_lines[j])
555  						printf("startup node %d\n", st->nodeid);
556  					else
557  						printf("startup %s", node_lines[j]);
558  					break;
559  				}
560  				if (!found_node)
561  					printf("startup node %d\n", st->nodeid);
562  			}
563  		}
564  	
565  		if (all_count && fence_count) {
566  			for (i = 0; i < all_count; i++) {
567  				for (j = 0; j < fence_count; j++) {
568  					if (all_ids[i] != fence_ids[j])
569  						continue;
570  					if (!fence_lines[j]) {
571  						printf("fence %d no data\n", fence_ids[j]);
572  					} else {
573  						printf("%s", fence_lines[j]);
574  						free(fence_lines[j]);
575  						fence_lines[j] = NULL;
576  					}
577  					break;
578  				}
579  			}
580  		}
581  	
582  		if (all_count && node_count) {
583  			for (i = 0; i < all_count; i++) {
584  				for (j = 0; j < node_count; j++) {
585  					if (all_ids[i] != node_ids[j])
586  						continue;
587  					if (!node_lines[j]) {
588  						printf("node %d no data\n", node_ids[j]);
589  					} else {
590  						printf("%s", node_lines[j]);
591  						free(node_lines[j]);
592  						node_lines[j] = NULL;
593  					}
594  					break;
595  				}
596  			}
597  		}
598  	
599  	 out_close:
600  		close(fd);
601  	 out:
602  		return rv;
603  	}
604  	
605  	int dlmc_node_info(char *name, int nodeid, struct dlmc_node *node)
606  	{
607  		struct dlmc_header h, *rh;
608  		char reply[sizeof(struct dlmc_header) + sizeof(struct dlmc_node)];
609  		int fd, rv;
610  	
611  		init_header(&h, DLMC_CMD_NODE_INFO, name, 0);
612  		h.data = nodeid;
613  	
614  		memset(reply, 0, sizeof(reply));
615  	
616  		fd = do_connect(DLMC_QUERY_SOCK_PATH);
617  		if (fd < 0) {
618  			rv = fd;
619  			goto out;
620  		}
621  	
622  		rv = do_write(fd, &h, sizeof(h));
623  		if (rv < 0)
624  			goto out_close;
625  	
626  		rv = do_read(fd, reply, sizeof(reply));
627  		if (rv < 0)
628  			goto out_close;
629  	
630  		rh = (struct dlmc_header *)reply;
631  		rv = rh->data;
632  		if (rv < 0)
633  			goto out_close;
634  	
635  		memcpy(node, (char *)reply + sizeof(struct dlmc_header),
636  		       sizeof(struct dlmc_node));
637  	 out_close:
638  		close(fd);
639  	 out:
640  		return rv;
641  	}
642  	
643  	int dlmc_lockspace_info(char *name, struct dlmc_lockspace *lockspace)
644  	{
645  		struct dlmc_header h, *rh;
646  		char reply[sizeof(struct dlmc_header) + sizeof(struct dlmc_lockspace)];
647  		int fd, rv;
648  	
649  		init_header(&h, DLMC_CMD_LOCKSPACE_INFO, name, 0);
650  	
651  		memset(reply, 0, sizeof(reply));
652  	
653  		fd = do_connect(DLMC_QUERY_SOCK_PATH);
654  		if (fd < 0) {
655  			rv = fd;
656  			goto out;
657  		}
658  	
659  		rv = do_write(fd, &h, sizeof(h));
660  		if (rv < 0)
661  			goto out_close;
662  	
663  		rv = do_read(fd, reply, sizeof(reply));
664  		if (rv < 0)
665  			goto out_close;
666  	
667  		rh = (struct dlmc_header *)reply;
668  		rv = rh->data;
669  		if (rv < 0)
670  			goto out_close;
671  	
672  		memcpy(lockspace, (char *)reply + sizeof(struct dlmc_header),
673  		       sizeof(struct dlmc_lockspace));
674  	 out_close:
675  		close(fd);
676  	 out:
677  		return rv;
678  	}
679  	
680  	int dlmc_lockspaces(int *count, struct dlmc_lockspace **lss)
681  	{
682  		struct dlmc_header h;
683  		int reply_len;
684  		int fd, rv, result;
685  	
686  		fd = do_connect(DLMC_QUERY_SOCK_PATH);
687  		if (fd < 0) {
688  			rv = fd;
689  			goto out;
690  		}
691  	
692  		init_header(&h, DLMC_CMD_LOCKSPACES, NULL, 0);
693  	
694  		rv = do_write(fd, &h, sizeof(h));
695  		if (rv < 0)
696  			goto out_close;
697  	
698  		rv = do_read(fd, &h, sizeof(h));
699  		if (rv <0)
700  			goto out_close;
701  	
702  		result = h.data;
703  		if (result < 0) {
704  			rv = result;
705  			goto out_close;
706  		}
707  	
708  		*count = result;
709  	
710  		reply_len = h.len - sizeof(struct dlmc_header);
711  		*lss = malloc(reply_len);
712  		if (!*lss) {
713  			rv = -1;
714  			goto out;
715  		}
716  		memset(*lss, 0, reply_len);
717  	
718  		rv = do_read(fd, *lss, reply_len);
719  		if (rv < 0) {
720  			free(*lss);
721  			goto out;
722  		}
723  	
724  		rv = 0;
725  	
726  	 out_close:
727  		close(fd);
728  	 out:
729  		return rv;
730  	}
731  	
732  	int dlmc_lockspace_nodes(char *name, int type, int max, int *count,
733  				 struct dlmc_node *nodes)
734  	{
735  		struct dlmc_header h, *rh;
736  		char *reply;
737  		int reply_len;
738  		int fd, rv, result, node_count;
739  	
740  		init_header(&h, DLMC_CMD_LOCKSPACE_NODES, name, 0);
741  		h.option = type;
742  		h.data = max;
743  	
744  		reply_len = sizeof(struct dlmc_header) +
745  			    (max * sizeof(struct dlmc_node));
746  		reply = malloc(reply_len);
747  		if (!reply) {
748  			rv = -1;
749  			goto out;
750  		}
751  		memset(reply, 0, reply_len);
752  	
753  		fd = do_connect(DLMC_QUERY_SOCK_PATH);
754  		if (fd < 0) {
755  			rv = fd;
756  			goto out;
757  		}
758  	
759  		rv = do_write(fd, &h, sizeof(h));
760  		if (rv < 0)
761  			goto out_close;
762  	
763  		/* won't usually get back the full reply_len */
764  		do_read(fd, reply, reply_len);
765  	
766  		rh = (struct dlmc_header *)reply;
767  		result = rh->data;
768  		if (result < 0 && result != -E2BIG) {
769  			rv = result;
770  			goto out_close;
771  		}
772  	
773  		if (result == -E2BIG) {
774  			*count = -E2BIG;
775  			node_count = max;
776  		} else {
777  			*count = result;
778  			node_count = result;
779  		}
780  		rv = 0;
781  	
782  		memcpy(nodes, (char *)reply + sizeof(struct dlmc_header),
783  		       node_count * sizeof(struct dlmc_node));
784  	 out_close:
785  		close(fd);
786  	 out:
787  		return rv;
788  	}
789  	
790  	int dlmc_fs_connect(void)
791  	{
792  		return do_connect(DLMC_SOCK_PATH);
793  	}
794  	
795  	void dlmc_fs_disconnect(int fd)
796  	{
797  		close(fd);
798  	}
799  	
800  	int dlmc_fs_register(int fd, char *name)
801  	{
802  		struct dlmc_header h;
803  	
804  		init_header(&h, DLMC_CMD_FS_REGISTER, name, 0);
805  	
806  		return do_write(fd, &h, sizeof(h));
807  	}
808  	
809  	int dlmc_fs_unregister(int fd, char *name)
810  	{
811  		struct dlmc_header h;
812  	
813  		init_header(&h, DLMC_CMD_FS_UNREGISTER, name, 0);
814  	
815  		return do_write(fd, &h, sizeof(h));
816  	}
817  	
818  	int dlmc_fs_notified(int fd, char *name, int nodeid)
819  	{
820  		struct dlmc_header h;
821  	
822  		init_header(&h, DLMC_CMD_FS_NOTIFIED, name, 0);
823  		h.data = nodeid;
824  	
825  		return do_write(fd, &h, sizeof(h));
826  	}
827  	
828  	int dlmc_fs_result(int fd, char *name, int *type, int *nodeid, int *result)
829  	{
830  		struct dlmc_header h;
831  		int rv;
832  	
833  		rv = do_read(fd, &h, sizeof(h));
834  		if (rv < 0)
835  			goto out;
836  	
837  		strncpy(name, h.name, DLM_LOCKSPACE_LEN);
838  		*nodeid = h.option;
839  		*result = h.data;
840  	
841  		switch (h.command) {
842  		case DLMC_CMD_FS_REGISTER:
843  			*type = DLMC_RESULT_REGISTER;
844  			break;
845  		case DLMC_CMD_FS_NOTIFIED:
846  			*type = DLMC_RESULT_NOTIFIED;
847  			break;
848  		default:
849  			*type = 0;
850  		}
851  	 out:
852  		return rv;
853  	}
854  	
855  	int dlmc_deadlock_check(char *name)
856  	{
857  		struct dlmc_header h;
858  		int fd, rv;
859  	
860  		init_header(&h, DLMC_CMD_DEADLOCK_CHECK, name, 0);
861  	
862  		fd = do_connect(DLMC_SOCK_PATH);
863  		if (fd < 0) {
864  			rv = fd;
865  			goto out;
866  		}
867  	
868  		rv = do_write(fd, &h, sizeof(h));
869  		close(fd);
870  	 out:
871  		return rv;
872  	}
873  	
874  	int dlmc_fence_ack(char *name)
875  	{
876  		struct dlmc_header h;
877  		int fd, rv;
878  	
879  		init_header(&h, DLMC_CMD_FENCE_ACK, name, 0);
880  	
881  		fd = do_connect(DLMC_SOCK_PATH);
882  		if (fd < 0) {
883  			rv = fd;
884  			goto out;
885  		}
886  	
887  		rv = do_write(fd, &h, sizeof(h));
888  		close(fd);
889  	 out:
890  		return rv;
891  	}
892  	
893  	int dlmc_run_start(char *run_command, int len, int nodeid, uint32_t flags, char *run_uuid)
894  	{
895  		struct dlmc_header h;
896  		struct dlmc_header rh;
897  		char *cmdbuf;
898  		int fd, rv;
899  	
900  		cmdbuf = malloc(DLMC_RUN_COMMAND_LEN);
901  		if (!cmdbuf)
902  			return -1;
903  	
904  		memset(cmdbuf, 0, DLMC_RUN_COMMAND_LEN);
905  		strncpy(cmdbuf, run_command, DLMC_RUN_COMMAND_LEN-1);
906  	
907  		init_header(&h, DLMC_CMD_RUN_START, NULL, DLMC_RUN_COMMAND_LEN);
908  		h.data = nodeid;
909  		h.flags = flags;
910  	
911  		memset(&rh, 0, sizeof(rh));
912  	
913  		fd = do_connect(DLMC_SOCK_PATH);
914  		if (fd < 0) {
915  			rv = fd;
916  			goto out;
917  		}
918  	
919  		rv = do_write(fd, &h, sizeof(h));
920  		if (rv < 0)
921  			goto out_close;
922  	
923  		rv = do_write(fd, cmdbuf, DLMC_RUN_COMMAND_LEN);
924  		if (rv < 0)
925  			goto out_close;
926  	
927  		rv = do_read(fd, &rh, sizeof(rh));
928  		if (rv < 0)
929  			goto out_close;
930  	
931  		rv = rh.data;
932  		if (rv < 0)
933  			goto out_close;
934  	
935  		memcpy(run_uuid, rh.name, DLMC_RUN_UUID_LEN);
936  		rv = 0;
937  	
938  	 out_close:
939  		close(fd);
940  	 out:
941  		free(cmdbuf);
942  		return rv;
943  	}
944  	
945  	int dlmc_run_check(char *run_uuid, int len, int wait_sec, uint32_t flags,
946  			   uint32_t *check_status)
947  	{
948  		struct dlmc_header h;
949  		struct dlmc_header rh;
950  		struct dlmc_run_check_state state;
951  		uint64_t wait_start = 0;
952  		int fd, rv;
953  	
954  		init_header(&h, DLMC_CMD_RUN_CHECK, NULL, 0);
955  		h.flags = flags;
956  		init_header_name(&h, run_uuid, DLMC_RUN_UUID_LEN);
957  	
958  		memset(&rh, 0, sizeof(rh));
959  	
960  		fd = do_connect(DLMC_SOCK_PATH);
961  		if (fd < 0) {
962  			rv = fd;
963  			goto out;
964  		}
965  	
966  	 retry:
967  	
968  		rv = do_write(fd, &h, sizeof(h));
969  		if (rv < 0) {
970  			goto out_close;
971  		}
972  	
973  		rv = do_read(fd, &rh, sizeof(rh));
974  		if (rv < 0) {
975  			goto out_close;
976  		}
977  	
978  		rv = do_read(fd, &state, sizeof(state));
979  		if (rv < 0) {
980  			goto out_close;
981  		}
982  	
983  		if ((state.check_status & DLMC_RUN_STATUS_WAITING) && wait_sec) {
984  			if (!wait_start) {
985  				wait_start = time(NULL);
986  				sleep(1);
987  				goto retry;
988  			}
989  	
990  			if (time(NULL) - wait_start < wait_sec) {
991  				sleep(1);
992  				goto retry;
993  			}
994  		}
995  	
996  		*check_status = state.check_status;
997  		rv = 0;
998  	
999  	 out_close:
1000 		close(fd);
1001 	 out:
1002 		return rv;
1003 	}
1004 	
1005