/*
+ * $Id: dsi_getsess.c,v 1.7 2005-04-28 20:50:02 bfernhomberg Exp $
+ *
* Copyright (c) 1997 Adrian Sun (asun@zoology.washington.edu)
* All rights reserved. See COPYRIGHT.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
-#endif
+#endif /* HAVE_CONFIG_H */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <errno.h>
+#ifdef HAVE_UNISTD_H
#include <unistd.h>
-#include <sys/types.h>
+#endif /* HAVE_UNISTD_H */
#include <signal.h>
+
+/* POSIX.1 sys/wait.h check */
+#include <sys/types.h>
+#ifdef HAVE_SYS_WAIT_H
#include <sys/wait.h>
+#endif /* HAVE_SYS_WAIT_H */
+#ifndef WEXITSTATUS
+#define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8)
+#endif /* ! WEXITSTATUS */
+#ifndef WIFEXITED
+#define WIFEXITED(stat_val) (((stat_val) & 255) == 0)
+#endif /* ! WIFEXITED */
+
#include <sys/time.h>
-#include <syslog.h>
+#include <atalk/logger.h>
+#include <atalk/util.h>
#include <atalk/dsi.h>
#include <atalk/server_child.h>
switch (pid = dsi->proto_open(dsi)) {
case -1:
/* if we fail, just return. it might work later */
- syslog(LOG_ERR, "dsi_getsess: %m");
+ LOG(log_error, logtype_default, "dsi_getsess: %s", strerror(errno));
return dsi;
case 0: /* child. mostly handled below. */
/* using SIGQUIT is hokey, but the child might not have
* re-established its signal handler for SIGTERM yet. */
if (server_child_add(children, CHILD_DSIFORK, pid) < 0) {
- syslog(LOG_ERR, "dsi_getsess: %m");
+ LOG(log_error, logtype_default, "dsi_getsess: %s", strerror(errno));
dsi->header.dsi_flags = DSIFL_REPLY;
dsi->header.dsi_code = DSIERR_SERVBUSY;
dsi_send(dsi);
* actual count. */
if ((children->count >= children->nsessions) &&
(dsi->header.dsi_command == DSIFUNC_OPEN)) {
- syslog(LOG_INFO, "dsi_getsess: too many connections");
+ LOG(log_info, logtype_default, "dsi_getsess: too many connections");
dsi->header.dsi_flags = DSIFL_REPLY;
dsi->header.dsi_code = DSIERR_TOOMANY;
dsi_send(dsi);
- exit(1);
+ exit(EXITERR_CLNT);
}
/* get rid of some stuff */
break;
default: /* just close */
- syslog(LOG_INFO, "DSIUnknown %d", dsi->header.dsi_command);
+ LOG(log_info, logtype_default, "DSIUnknown %d", dsi->header.dsi_command);
dsi->proto_close(dsi);
- exit(1);
+ exit(EXITERR_CLNT);
}
}