glusterfs/tests/bugs/cli/bug-1169302.c
Niels de Vos e2525785e0 gfapi: create statedump when glusterd requests it
When GlusterD sends the STATEDUMP procedure to the libgfapi client, the
client checks if it matches the PID that should take the statedump. If
so, it will do a statedump for the glfs_t that is connected to this mgmt
connection.

BUG: 1169302
Change-Id: I70d6a1f4f19d525377aebc8fa57f51e513b92d84
See-also: http://review.gluster.org/9228
Signed-off-by: Poornima G <pgurusid@redhat.com>
[ndevos: separated patch from 9228]
Reviewed-on: https://review.gluster.org/16415
Reviewed-by: Niels de Vos <ndevos@redhat.com>
Tested-by: Niels de Vos <ndevos@redhat.com>
Smoke: Gluster Build System <jenkins@build.gluster.org>
CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com>
Reviewed-by: Prashanth Pai <ppai@redhat.com>
2017-01-24 05:42:57 -05:00

79 lines
1.5 KiB
C

#include <errno.h>
#include <stdio.h>
#include <signal.h>
#include <glusterfs/api/glfs.h>
#include <glusterfs/api/glfs-handles.h>
int keep_running = 1;
void stop_running(int sig)
{
if (sig == SIGTERM)
keep_running = 0;
}
int
main (int argc, char *argv[])
{
glfs_t *fs = NULL;
int ret = 0;
glfs_fd_t *fd = NULL;
char *filename = NULL;
char *logfile = NULL;
char *host = NULL;
if (argc != 5) {
return -1;
}
host = argv[2];
logfile = argv[3];
filename = argv[4];
/* setup signal handler for exiting */
signal (SIGTERM, stop_running);
fs = glfs_new (argv[1]);
if (!fs) {
return -1;
}
ret = glfs_set_volfile_server (fs, "tcp", host, 24007);
if (ret < 0) {
return -1;
}
ret = glfs_set_logging (fs, logfile, 7);
if (ret < 0) {
return -1;
}
ret = glfs_init (fs);
if (ret < 0) {
return -1;
}
fd = glfs_creat (fs, filename, O_RDWR, 0644);
if (!fd) {
return -1;
}
/* sleep until SIGTERM has been received */
while (keep_running) {
sleep (1);
}
ret = glfs_close (fd);
if (ret < 0) {
return -1;
}
ret = glfs_fini (fs);
if (ret < 0) {
return -1;
}
return 0;
}