#endif /* DEBUG_MUTEX */
+/* These probably should be subroutines */
+#define Pw(x) \
+ do { int errstat; if ((errstat=rwl_writelock(&(x)))) \
+ e_msg(__FILE__, __LINE__, M_ABORT, 0, "Write lock lock failure. ERR=%s\n",\
+ strerror(errstat)); \
+ } while(0)
+
+#define Vw(x) \
+ do { int errstat; if ((errstat=rwl_writeunlock(&(x)))) \
+ e_msg(__FILE__, __LINE__, M_ABORT, 0, "Write lock unlock failure. ERR=%s\n",\
+ strerror(errstat)); \
+ } while(0)
+
+
/*
* The digit following Dmsg and Emsg indicates the number of substitutions in
* the message string. We need to do this kludge because non-GNU compilers
return 1;
}
mdb->connected = FALSE;
-#ifdef needed
- if (pthread_mutex_init(&mdb->mutex, NULL) != 0) {
- Mmsg1(&mdb->errmsg, "Unable to initialize DB mutex. ERR=%s\n", strerror(errno));
- V(mutex);
- return 0;
- }
-#endif
if (rwl_init(&mdb->lock) != 0) {
Mmsg1(&mdb->errmsg, "Unable to initialize DB lock. ERR=%s\n", strerror(errno));
extern int r_first;
extern int r_last;
extern struct s_res resources[];
-extern int console_msg_pending;
extern char my_name[];
/* Imported functions */
extern int r_first;
extern int r_last;
extern struct s_res resources[];
-extern int console_msg_pending;
extern char my_name[];
/* Imported functions */
extern struct s_res resources[];
extern int console_msg_pending;
extern FILE *con_fd;
-extern pthread_mutex_t con_mutex;
+extern brwlock_t con_lock;
/* Imported functions */
return 1;
}
+static void con_lock_release(void *arg)
+{
+ Vw(con_lock);
+}
+
void do_messages(UAContext *ua, char *cmd)
{
char msg[2000];
int mlen;
int do_truncate = FALSE;
- P(con_mutex);
+ Pw(con_lock);
+ pthread_cleanup_push(con_lock_release, (void *)NULL);
rewind(con_fd);
while (fgets(msg, sizeof(msg), con_fd)) {
mlen = strlen(msg);
}
console_msg_pending = FALSE;
ua->user_notified_msg_pending = FALSE;
- V(con_mutex);
+ pthread_cleanup_pop(0);
+ Vw(con_lock);
}
for (i=0; i<len; ) {
if (rem < 6) {
reg <<= 8;
- reg |= (uint8_t)bin[i++];
+ reg |= (int8_t)bin[i++];
rem += 8;
}
save = reg;
char junk[100];
int i;
- for (i=0; i < 100; i++) {
+#ifdef xxxx
+ for (i=0; i < 1000; i++) {
bin_to_base64(buf, (char *)&xx, 4);
printf("xx=%s\n", buf);
xx++;
}
+#endif
+ junk[0] = 0xFF;
+ for (i=1; i<100; i++) {
+ junk[i] = junk[i-1]-1;
+ }
len = bin_to_base64(buf, junk, 16);
printf("len=%d junk=%s\n", len, buf);
return 0;
struct stat statp;
struct stat statn;
int debug_level = 0;
+ char *p;
+ time_t t = 1028712799;
if (argc > 1 && strcmp(argv[1], "-v") == 0)
debug_level++;
base64_init();
my_glob.gl_offs = 0;
- glob("/etc/*", GLOB_MARK, errfunc, &my_glob);
+ glob("/etc/grub.conf", GLOB_MARK, errfunc, &my_glob);
for (i=0; my_glob.gl_pathv[i]; i++) {
fname = my_glob.gl_pathv[i];
continue;
}
encode_stat(where, &statp);
+ p = where;
+ p += to_base64((intmax_t)(statp.st_atime), p);
+ *p++ = ' ';
+ p += to_base64((intmax_t)t, p);
+ printf("%s %s\n", fname, where);
+
+#ifdef xxxx
+ printf("%s %lld\n", "st_dev", (intmax_t)statp.st_dev);
+ printf("%s %lld\n", "st_ino", (intmax_t)statp.st_ino);
+ printf("%s %lld\n", "st_mode", (intmax_t)statp.st_mode);
+ printf("%s %lld\n", "st_nlink", (intmax_t)statp.st_nlink);
+ printf("%s %lld\n", "st_uid", (intmax_t)statp.st_uid);
+ printf("%s %lld\n", "st_gid", (intmax_t)statp.st_gid);
+ printf("%s %lld\n", "st_rdev", (intmax_t)statp.st_rdev);
+ printf("%s %lld\n", "st_size", (intmax_t)statp.st_size);
+ printf("%s %lld\n", "st_blksize", (intmax_t)statp.st_blksize);
+ printf("%s %lld\n", "st_blocks", (intmax_t)statp.st_blocks);
+ printf("%s %lld\n", "st_atime", (intmax_t)statp.st_atime);
+ printf("%s %lld\n", "st_mtime", (intmax_t)statp.st_mtime);
+ printf("%s %lld\n", "st_ctime", (intmax_t)statp.st_ctime);
+#endif
+
if (debug_level)
printf("%s: len=%d val=%s\n", fname, strlen(where), where);
decode_stat(where, &statn);
+#ifdef xxx
if (statp.st_dev != statn.st_dev ||
statp.st_ino != statn.st_ino ||
statp.st_mode != statn.st_mode ||
printf("%s: %s\n", fname, where);
printf("NOT EQAL\n");
}
+#endif
}
globfree(&my_glob);
int console_msg_pending = 0;
char con_fname[1000];
FILE *con_fd = NULL;
-pthread_mutex_t con_mutex = PTHREAD_MUTEX_INITIALIZER;
+brwlock_t con_lock;
/* Forward referenced functions */
sprintf(con_fname, "%s/%s.conmsg", wd, my_name);
fd = open(con_fname, O_CREAT|O_RDWR|O_BINARY, 0600);
if (fd == -1) {
- Emsg2(M_ERROR_TERM, 0, "Could not open console message file %s: ERR=%s\n",
+ Emsg2(M_ERROR_TERM, 0, _("Could not open console message file %s: ERR=%s\n"),
con_fname, strerror(errno));
}
if (lseek(fd, 0, SEEK_END) > 0) {
close(fd);
con_fd = fopen(con_fname, "a+");
if (!con_fd) {
- Emsg2(M_ERROR, 0, "Could not open console message file %s: ERR=%s\n",
+ Emsg2(M_ERROR, 0, _("Could not open console message file %s: ERR=%s\n"),
con_fname, strerror(errno));
}
+ if (rwl_init(&con_lock) != 0) {
+ Emsg1(M_ERROR_TERM, 0, _("Could not get con mutex: ERR=%s\n"),
+ strerror(errno));
+ }
}
/*
Dmsg0(200, "Console file not open.\n");
}
if (con_fd) {
- P(con_mutex);
+ Pw(con_lock); /* get write lock on console message file */
errno = 0;
bstrftime(cmd, sizeof(cmd), time(NULL));
len = strlen(cmd);
fwrite(msg, len, 1, con_fd);
fflush(con_fd);
console_msg_pending = TRUE;
- V(con_mutex);
+ Vw(con_lock);
}
break;
case MD_SYSLOG:
pid_t pid;
fprintf(stderr, "Kaboom! %s, %s got signal %d. Attempting traceback.\n",
- NPRT(exename), NPRT(my_name), sig);
+ exename, my_name, sig);
if (strlen(exepath) + 12 > (int)sizeof(btpath)) {
strcpy(btpath, "btraceback");
/* */
#define VERSION "1.24"
#define VSTRING "1"
-#define DATE "06 August 2002"
-#define LSMDATE "06Aug02"
+#define DATE "07 August 2002"
+#define LSMDATE "07Aug02"
/* Debug flags */
#define DEBUG 1