SRCS:= conf.c bones_server.c soap_ops.c soap_ps_calls.c common.c \
${is_prefix}Server.c ${ps_prefix}Client.c ${ws_prefix}C.c \
- ws_ps_typeref.c ws_is_typeref.c db_ops.c context.c common_server.c
+ ws_ps_typeref.c ws_is_typeref.c db_ops.c context.c
EXA_TEST_SRCS:=jpis-test.c ${is_prefix}Client.c ${is_prefix}C.c context.c db_ops.c conf.c ws_is_typeref.c common.c
EXA_DB_SRCS:=jpis-db-internal.c db_ops.c conf.c context.c ws_is_typeref.c common.c
COMMONLIB:=-lglite_jp_common_${nothrflavour}
SRVCOMMONLIB:=-lglite_jp_server_common
-BONESLIB:=-lglite_lb_server_bones
+BONESLIB:=-lglite_lbu_server_bones
TRIOLIB:=-lglite_lbu_trio
GSSLIB:=-lglite_security_gss_${nothrflavour}
soap_ops.o: soap_ops.c jp_H.h ${is_prefix}.nsmap soap_version.h db_ops.h ws_ps_typeref.h ws_is_typeref.h context.h
ws_ps_typeref.o: ws_ps_typeref.c ${ps_prefix}H.h ws_typemap.h ws_ps_typeref.h soap_version.h
ws_is_typeref.o: ws_is_typeref.c ${is_prefix}H.h ws_typemap.h ws_is_typeref.h soap_version.h
-comon_server.o: common_server.c common_server.h
jpis-client.o: jpis-client.c ${is_prefix}H.h soap_version.h
jpis-test.o: jpis-client.c ${is_prefix}H.h soap_version.h
conf.o: conf.c ${is_prefix}H.h soap_version.h
#include <glite/jp/types.h>
#include <glite/jp/context.h>
-#include <glite/lb/srvbones.h>
+#include <glite/lbu/srvbones.h>
#include <stdsoap2.h>
#include <glite/security/glite_gss.h>
#include "soap_ps_calls.h"
#include "context.h"
#include "common.h"
-#include "common_server.h"
#include "soap_version.h"
#include "jp_H.h"
}
/* daemonize */
- if (!conf->debug) glite_jpis_daemonize("glite-jp-indexd", conf->pidfile, conf->logfile);
+ if (!conf->debug) glite_srvbones_daemonize("glite-jp-indexd", conf->pidfile, conf->logfile);
/* XXX preliminary support for plugins
for (i=0; conf->plugins[i]; i++)
+++ /dev/null
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <signal.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <string.h>
-
-/* TODO: belongs to server-bones */
-
-int glite_jpis_daemonize(const char *servername, const char *custom_pidfile, const char *custom_logfile) {
- int lfd, opid;
- FILE *fpid;
- pid_t master;
- char *pidfile, *logfile;
-
- if (!custom_logfile) {
- asprintf(&logfile, "%s/%s.log", geteuid() == 0 ? "/var/log" : getenv("HOME"), servername);
- } else {
- logfile = NULL;
- }
- lfd = open(logfile ? logfile : custom_logfile,O_CREAT|O_TRUNC|O_WRONLY,0600);
- if (lfd < 0) {
- fprintf(stderr,"%s: %s: %s\n",servername,logfile,strerror(errno));
- free(logfile);
- return 0;
- }
-// printf("logfile: %s\n", logfile ? logfile : custom_logfile);
- free(logfile);
-
- if (daemon(0,1) == -1) {
- perror("can't daemonize");
- return 0;
- }
- dup2(lfd,1);
- dup2(lfd,2);
-
- if (!custom_pidfile) {
- asprintf(&pidfile, "%s/%s.pid", geteuid() == 0 ? "/var/run" : getenv("HOME"), servername);
- } else {
- pidfile = strdup(custom_pidfile);
- }
-// printf("pidfile: %s\n", pidfile ? pidfile : custom_pidfile);
- setpgrp(); /* needs for signalling */
- master = getpid();
- fpid = fopen(pidfile,"r");
- if ( fpid )
- {
- opid = -1;
-
- if ( fscanf(fpid,"%d",&opid) == 1 )
- {
- if ( !kill(opid,0) )
- {
- fprintf(stderr,"%s: another instance running, pid = %d\n",servername,opid);
- return 0;
- }
- else if (errno != ESRCH) { perror("kill()"); return 0; }
- }
- fclose(fpid);
- } else if (errno != ENOENT) { perror(pidfile); free(pidfile); return 0; }
-
- if (((fpid = fopen(pidfile, "w")) == NULL) ||
- (fprintf(fpid, "%d", getpid()) <= 0) ||
- (fclose(fpid) != 0)) {
- perror(pidfile);
- free(pidfile);
- return 0;
- }
-
- free(pidfile);
- return 1;
-}
+++ /dev/null
-#ifndef GLITE_JPIS_COMMON_SERVER_H
-#define GLITE_JPIS_COMMON_SERVER_H
-
-int glite_jpis_daemonize(const char *servername, const char *custom_pidfile, const char *custom_logfile);
-
-#endif
dotless_soap_ver:=${shell echo ${gsoap_version} | tr -d . }
COMMONLIB:=-lglite_jp_common_${nothrflavour}
-BONESLIB:=-lglite_lb_server_bones
+BONESLIB:=-lglite_lbu_server_bones
GSOAPLIB:=-L${stagedir}/lib -lglite_security_gsoap_plugin_${dotless_soap_ver}_${nothrflavour}
TRIOLIB:=-lglite_lbu_trio
LIBTARLIB:=-L${libtar_prefix}/lib -ltar
#include "glite/jp/types.h"
#include "glite/jp/context.h"
-#include "glite/lb/srvbones.h"
+#include "glite/lbu/srvbones.h"
#include "glite/security/glite_gss.h"
#include <stdsoap2.h>
top_srcdir=.
stagedir=.
globalprefix=glite
-lbprefix=lb
+lbutilsprefix=lbu
package=glite-lb-server-bones
version=0.0.1
PREFIX=/opt/glite
LINK:=libtool --mode=link ${CC} -rpath ${stagedir}/lib ${LDFLAGS}
INSTALL:=libtool --mode=install install
-STATICLIB:=libglite_lb_server_bones.a
-LTLIB:=libglite_lb_server_bones.la
+STATICLIB:=libglite_lbu_server_bones.a
+LTLIB:=libglite_lbu_server_bones.la
OBJS:=srvbones.o
LOBJS:=${OBJS:.o=.lo}
doc:
install:
- mkdir -p ${PREFIX}/include/${globalprefix}/${lbprefix}
+ mkdir -p ${PREFIX}/include/${globalprefix}/${lbutilsprefix}
mkdir -p ${PREFIX}/lib
${INSTALL} -m 644 ${LTLIB} ${PREFIX}/lib
if [ x${DOSTAGE} = xyes ]; then \
${INSTALL} -m 644 ${STATICLIB} ${PREFIX}/lib ; \
- cd ${top_srcdir}/interface && install -m 644 ${HDRS} ${PREFIX}/include/${globalprefix}/${lbprefix} ; \
+ cd ${top_srcdir}/interface && install -m 644 ${HDRS} ${PREFIX}/include/${globalprefix}/${lbutilsprefix} ; \
fi
clean:
struct sigaction sa;
sigset_t sset;
int sock_slave[2], i;
+ int pstat;
assert(service_table);
{
int pid;
- while ( (pid = waitpid(-1, NULL, WNOHANG)) > 0 )
+ while ( (pid = waitpid(-1, &pstat, WNOHANG)) > 0 )
{
+ if (WIFEXITED(pstat)) {
+ dprintf(("[master] Slave %d exited with return code %d.\n", pid, WEXITSTATUS(pstat)));
+ if (WEXITSTATUS(pstat)) {
+ syslog(LOG_ERR, "Slave %d exited with return code %d.\n", pid, WEXITSTATUS(pstat));
+ }
+ }
+ if (WIFSIGNALED(pstat)) {
+ dprintf(("[master] Slave %d terminated with signal %d.\n", pid, WTERMSIG(pstat)));
+ switch (WTERMSIG(pstat)) {
+ case SIGINT:
+ case SIGTERM:
+ case SIGUSR1: if (die) break;
+ default:
+ syslog(LOG_ERR, "Slave %d terminated with signal %d.\n", pid, WTERMSIG(pstat));
+ break;
+ }
+ }
if ( !die )
{
int newpid = slave(slave_data_init, sock_slave[1]);
FD_ZERO(&fds);
- FD_SET(sock, &fds);
+ if ( conn < 0 || !first_request) FD_SET(sock, &fds);
if ( conn >= 0 ) FD_SET(conn, &fds);
if ( conn > sock ) max = conn;
if ( services[srv].on_new_conn_hnd
&& (ret = services[srv].on_new_conn_hnd(conn, to.tv_sec >= 0 ? &to : NULL, clnt_data)) )
{
- dprintf(("[%d] Connection not estabilished, err = %d.\n", getpid(),ret));
- if ( !debug ) syslog(LOG_ERR, "Connection not estabilished, err = %d.\n",ret);
+ dprintf(("[%d] Connection not established, err = %d.\n", getpid(),ret));
+ if ( !debug ) syslog(LOG_ERR, "Connection not established, err = %d.\n",ret);
close(conn);
conn = srv = -1;
if (ret < 0) exit(1);
-I${globus_prefix}/include/${nothrflavour} #gridsite needs this
ifdef LB_PROF
- SRVBONES_LIB:= ${stagedir}/lib/libglite_lb_server_bones.la
+ SRVBONES_LIB:= ${stagedir}/lib/libglite_lbu_server_bones.la
LB_COMMON_LIB:=${stagedir}/lib/libglite_lb_common_${nothrflavour}.la
CFLAGS:=${CFLAGS} -pg -g
LDFLAGS:=${LDFLAGS} -pg
else
- SRVBONES_LIB:= -L${stagedir}/lib -lglite_lb_server_bones
+ SRVBONES_LIB:= -L${stagedir}/lib -lglite_lbu_server_bones
LB_COMMON_LIB:=-lglite_lb_common_${nothrflavour}
LDFLAGS:= -L${stagedir}/lib
endif
#include "glite/jobid/cjobid.h"
#include "glite/security/glite_gss.h"
-#include "glite/lb/srvbones.h"
+#include "glite/lbu/srvbones.h"
#include "glite/lb/context.h"
#include "glite/lb/mini_http.h"
#include "glite/lb/context-int.h"
# defaults
-top_srcdir=.
+top_srcdir=..
stagedir=.
-distdir=.
globalprefix=glite
-lbprefix=lb
+lbutilsprefix=lbu
package=glite-lb-server-bones
version=0.0.1
PREFIX=/opt/glite
-glite_location=/opt/glite
-
CC=gcc
-include Makefile.inc
-include ../project/version.properties
-version=${module.version}
-
VPATH=${top_srcdir}/src:${top_srcdir}/examples
DEBUG:=-g -O0 -Wall
-CFLAGS:= ${DEBUG} -I${top_srcdir}/interface
+CFLAGS:= ${DEBUG} -I${top_srcdir}/interface -D_GNU_SOURCE
LDFLAGS:=
ifdef LB_PROF
LINK:=libtool --mode=link ${CC} -rpath ${stagedir}/lib ${LDFLAGS}
INSTALL:=libtool --mode=install install
-STATICLIB:=libglite_lb_server_bones.a
-LTLIB:=libglite_lb_server_bones.la
+STATICLIB:=libglite_lbu_server_bones.a
+LTLIB:=libglite_lbu_server_bones.la
OBJS:=srvbones.o
LOBJS:=${OBJS:.o=.lo}
doc:
-dist: distsrc distbin
-
-distsrc:
- mkdir -p ${top_srcdir}/${package}-${version}
- cd ${top_srcdir} && GLOBIGNORE="${package}-${version}" && cp -Rf * ${package}-${version}
- cd ${top_srcdir} && tar -czf ${distdir}/${package}-${version}_src.tar.gz --exclude-from=project/tar_exclude ${package}-${version}
- rm -rf ${top_srcdir}/${package}-${version}
-
-distbin:
- $(MAKE) install PREFIX=`pwd`/tmpbuilddir${stagedir}
- save_dir=`pwd`; cd tmpbuilddir${stagedir} && tar -czf $$save_dir/${top_srcdir}/${distdir}/${package}-${version}_bin.tar.gz *; cd $$save_dir
- rm -rf tmpbuilddir
-
install:
- mkdir -p ${PREFIX}/include/${globalprefix}/${lbprefix}
+ mkdir -p ${PREFIX}/include/${globalprefix}/${lbutilsprefix}
mkdir -p ${PREFIX}/lib
${INSTALL} -m 644 ${LTLIB} ${PREFIX}/lib
- if [ x${DOSTAGE} = xyes ]; then \
- ${INSTALL} -m 644 ${STATICLIB} ${PREFIX}/lib ; \
- cd ${top_srcdir}/interface && install -m 644 ${HDRS} ${PREFIX}/include/${globalprefix}/${lbprefix} ; \
- fi
+ ${INSTALL} -m 644 ${STATICLIB} ${PREFIX}/lib ; \
+ cd ${top_srcdir}/interface && install -m 644 ${HDRS} ${PREFIX}/include/${globalprefix}/${lbutilsprefix}
clean:
+ rm -rvf *.o *.lo .libs lib* srv_example cnt_example
+ rm -rvf log.xml project/ rpmbuild/ RPMS/ tgz/
%.o: %.c
${COMPILE} -c $<
size_t table_sz,
int dbg);
+/**
+ * helper common function to daemonize server
+ *
+ * \returns 1 OK, 0 error writtten to stderr
+ */
+int glite_srvbones_daemonize(const char *servername, const char *custom_pidfile, const char *custom_logfile);
+
#ifdef __cplusplus
}
#endif
--- /dev/null
+# $Id$
+# $Name$
+module.version=1.0.0
+module.age=1
struct sigaction sa;
sigset_t sset;
int sock_slave[2], i;
+ int pstat;
assert(service_table);
{
int pid;
- while ( (pid = waitpid(-1, NULL, WNOHANG)) > 0 )
+ while ( (pid = waitpid(-1, &pstat, WNOHANG)) > 0 )
{
+ if (WIFEXITED(pstat)) {
+ dprintf(("[master] Slave %d exited with return code %d.\n", pid, WEXITSTATUS(pstat)));
+ if (WEXITSTATUS(pstat)) {
+ syslog(LOG_ERR, "Slave %d exited with return code %d.\n", pid, WEXITSTATUS(pstat));
+ }
+ }
+ if (WIFSIGNALED(pstat)) {
+ dprintf(("[master] Slave %d terminated with signal %d.\n", pid, WTERMSIG(pstat)));
+ switch (WTERMSIG(pstat)) {
+ case SIGINT:
+ case SIGTERM:
+ case SIGUSR1: if (die) break;
+ default:
+ syslog(LOG_ERR, "Slave %d terminated with signal %d.\n", pid, WTERMSIG(pstat));
+ break;
+ }
+ }
if ( !die )
{
int newpid = slave(slave_data_init, sock_slave[1]);
return 0;
}
+int glite_srvbones_daemonize(const char *servername, const char *custom_pidfile, const char *custom_logfile) {
+ int lfd, opid;
+ FILE *fpid;
+ pid_t master;
+ char *pidfile, *logfile;
+
+ if (!custom_logfile) {
+ asprintf(&logfile, "%s/%s.log", geteuid() == 0 ? "/var/log" : getenv("HOME"), servername);
+ } else {
+ logfile = NULL;
+ }
+ lfd = open(logfile ? logfile : custom_logfile,O_CREAT|O_TRUNC|O_WRONLY,0600);
+ if (lfd < 0) {
+ fprintf(stderr,"%s: %s: %s\n",servername,logfile,strerror(errno));
+ free(logfile);
+ return 0;
+ }
+// printf("logfile: %s\n", logfile ? logfile : custom_logfile);
+ free(logfile);
+
+ if (daemon(0,1) == -1) {
+ perror("can't daemonize");
+ return 0;
+ }
+ dup2(lfd,1);
+ dup2(lfd,2);
+
+ if (!custom_pidfile) {
+ asprintf(&pidfile, "%s/%s.pid", geteuid() == 0 ? "/var/run" : getenv("HOME"), servername);
+ } else {
+ pidfile = strdup(custom_pidfile);
+ }
+// printf("pidfile: %s\n", pidfile ? pidfile : custom_pidfile);
+ setpgrp(); /* needs for signalling */
+ master = getpid();
+ fpid = fopen(pidfile,"r");
+ if ( fpid )
+ {
+ opid = -1;
+
+ if ( fscanf(fpid,"%d",&opid) == 1 )
+ {
+ if ( !kill(opid,0) )
+ {
+ fprintf(stderr,"%s: another instance running, pid = %d\n",servername,opid);
+ return 0;
+ }
+ else if (errno != ESRCH) { perror("kill()"); return 0; }
+ }
+ fclose(fpid);
+ } else if (errno != ENOENT) { perror(pidfile); free(pidfile); return 0; }
+
+ if (((fpid = fopen(pidfile, "w")) == NULL) ||
+ (fprintf(fpid, "%d", getpid()) <= 0) ||
+ (fclose(fpid) != 0)) {
+ perror(pidfile);
+ free(pidfile);
+ return 0;
+ }
+
+ free(pidfile);
+ return 1;
+}
+
static int dispatchit(int sock_slave, int sock, int sidx)
{
struct sockaddr_in a;
FD_ZERO(&fds);
- FD_SET(sock, &fds);
+ if ( conn < 0 || !first_request) FD_SET(sock, &fds);
if ( conn >= 0 ) FD_SET(conn, &fds);
if ( conn > sock ) max = conn;
if ( services[srv].on_new_conn_hnd
&& (ret = services[srv].on_new_conn_hnd(conn, to.tv_sec >= 0 ? &to : NULL, clnt_data)) )
{
- dprintf(("[%d] Connection not estabilished, err = %d.\n", getpid(),ret));
- if ( !debug ) syslog(LOG_ERR, "Connection not estabilished, err = %d.\n",ret);
+ dprintf(("[%d] Connection not established, err = %d.\n", getpid(),ret));
+ if ( !debug ) syslog(LOG_ERR, "Connection not established, err = %d.\n",ret);
close(conn);
conn = srv = -1;
if (ret < 0) exit(1);