1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
|
#include <glusterfs/api/glfs.h>
#include <glusterfs/api/glfs-handles.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#define NO_INIT 1
glfs_t *
setup_new_client(char *hostname, char *volname, char *log_file, int flag)
{
int ret = 0;
glfs_t *fs = NULL;
fs = glfs_new (volname);
if (!fs) {
fprintf (stderr, "\nglfs_new: returned NULL (%s)\n",
strerror (errno));
goto error;
}
ret = glfs_set_volfile_server (fs, "tcp", hostname, 24007);
if (ret < 0) {
fprintf (stderr, "\nglfs_set_volfile_server failed ret:%d (%s)\n",
ret, strerror (errno));
goto error;
}
ret = glfs_set_logging (fs, log_file, 7);
if (ret < 0) {
fprintf (stderr, "\nglfs_set_logging failed with ret: %d (%s)\n",
ret, strerror (errno));
goto error;
}
if (flag == NO_INIT)
goto out;
ret = glfs_init (fs);
if (ret < 0) {
fprintf (stderr, "\nglfs_init failed with ret: %d (%s)\n",
ret, strerror (errno));
goto error;
}
out:
return fs;
error:
return NULL;
}
int
main (int argc, char *argv[])
{
int ret = 0;
glfs_t *fs1 = NULL;
glfs_t *fs2 = NULL;
glfs_t *fs3 = NULL;
char *volname = NULL;
char *log_file = NULL;
char *hostname = NULL;
if (argc != 4) {
fprintf (stderr,
"Expect following args %s <hostname> <Vol> <log file location>\n"
, argv[0]);
return -1;
}
hostname = argv[1];
volname = argv[2];
log_file = argv[3];
fs1 = setup_new_client (hostname, volname, log_file, NO_INIT);
if (!fs1) {
fprintf (stderr, "\nsetup_new_client: returned NULL (%s)\n",
strerror (errno));
goto error;
}
fs2 = setup_new_client (hostname, volname, log_file, 0);
if (!fs2) {
fprintf (stderr, "\nsetup_new_client: returned NULL (%s)\n",
strerror (errno));
goto error;
}
fs3 = setup_new_client (hostname, volname, log_file, 0);
if (!fs3) {
fprintf (stderr, "\nsetup_new_client: returned NULL (%s)\n",
strerror (errno));
goto error;
}
ret = glfs_fini (fs3);
if (ret < 0) {
fprintf (stderr, "glfs_fini failed with ret: %d (%s)\n",
ret, strerror (errno));
goto error;
}
/* The crash is seen in gf_log_flush_timeout_cbk(), and this gets
* triggered when 30s timer expires, hence the sleep of 31s
*/
sleep (31);
ret = glfs_fini (fs2);
if (ret < 0) {
fprintf (stderr, "glfs_fini failed with ret: %d (%s)\n",
ret, strerror (errno));
goto error;
}
ret = glfs_init (fs1);
if (ret < 0) {
fprintf (stderr, "\nglfs_init failed with ret: %d (%s)\n",
ret, strerror (errno));
goto error;
}
ret = glfs_fini (fs1);
if (ret < 0) {
fprintf (stderr, "glfs_fini failed with ret: %d (%s)\n",
ret, strerror (errno));
goto error;
}
return 0;
error:
return -1;
}
|