[Linux-cluster] Simple dlm demo program, and a bug...
Daniel Phillips
phillips at redhat.com
Wed Oct 13 14:37:26 UTC 2004
Hi Patrick,
With the "pad" commented out, it segfaults, with the pad it runs fine. So
something is stepping out of bounds.
Regards,
Daniel
-----------------------------
#include <stdlib.h>
#include <unistd.h>
#include <stdint.h>
#include <errno.h>
#include <string.h>
#include <stdio.h>
#include <linux/major.h>
#include <sys/types.h>
#include <libdlm.h>
#define warn(string, args...) do { fprintf(stderr, "%s: " string "\n", __func__, ##args); } while (0)
#define error(string, args...) do { warn(string, ##args); } while (0)
void my_ast(void *arg)
{
warn("ast got arg %p", arg);
}
int main(void)
{
int running = 1;
int fd;
//int pad;
struct dlm_lksb *lksb;
if ((fd = dlm_get_fd()) < 0)
error("dlm error %i, %s", errno, strerror(errno));
switch (fork()) {
case -1:
error("fork error %i, %s", errno, strerror(errno));
case 0:
while (running)
dlm_dispatch(fd);
printf("dispatch exiting\n");
return 0;
}
if (dlm_lock(LKM_PWMODE, lksb, LKF_NOQUEUE, "foo", 3,
0, my_ast, (void *)&fd, NULL, NULL) < 0)
error("dlm error %i, %s\n", errno, strerror(errno));
sleep(1);
if (dlm_unlock(lksb->sb_lkid, 0, lksb, NULL) < 0)
error("dlm error %i, %s\n", errno, strerror(errno));
running = 0;
return 0;
}
More information about the Linux-cluster
mailing list