Commit f4fa4dfc authored by Pekka Pessi's avatar Pekka Pessi

su/su.c, tport/tport_tls.c, etc.: using HAVE_SIGNAL.

Moved SIGPIPE check from configure.ac to m4/sac-su2.m4.

darcs-hash:20070201121044-65a35-14bcf08fcb2d0b9fd2e9e4c2376d18e6c5f26aaf.gz
parent 8bc107c8
......@@ -104,10 +104,6 @@ AC_HEADER_STDC
### checks for declarations
### -----------------------
AC_CHECK_DECL([SIGPIPE], [
AC_DEFINE([HAVE_SIGPIPE], 1, [Define to 1 if you have SIGPIPE])],,[
#include <signal.h>
])
### checks for types
### ----------------
......
......@@ -38,7 +38,10 @@
#include <string.h>
#include <stdio.h>
#include <assert.h>
#if HAVE_SIGNAL
#include <signal.h>
#endif
typedef struct context_s context_t;
#define NTH_SITE_MAGIC_T context_t
......@@ -77,7 +80,10 @@ static int request(context_t *context,
http_t const *http,
char const *path);
su_msg_r server_intr_msg = SU_MSG_R_INIT;
#if HAVE_SIGNAL
static RETSIGTYPE server_intr_handler(int signum);
#endif
static void server_break(context_t *c, su_msg_r msg, su_msg_arg_t *arg);
static msg_payload_t *read_payload(su_home_t *home, char const *fname);
......@@ -140,12 +146,12 @@ int main(int argc, char *argv[])
su_root_task(context->c_root),
server_break, 0);
#if HAVE_SIGNAL
signal(SIGINT, server_intr_handler);
#ifndef _WIN32
signal(SIGPIPE, server_intr_handler);
#if HAVE_SIGQUIT
signal(SIGQUIT, server_intr_handler);
signal(SIGHUP, server_intr_handler);
#endif
#endif
if (context->c_root) {
......
......@@ -32,14 +32,16 @@
#include "config.h"
#include <stdio.h>
#include <string.h>
#include <signal.h>
#include "sofia-sip/su.h"
#include "sofia-sip/su_log.h"
#include "sofia-sip/su_alloc.h"
#include <stdio.h>
#include <string.h>
#if HAVE_SIGNAL
#include <signal.h>
#endif
#if !SU_HAVE_BSDSOCK && !SU_HAVE_WINSOCK
#error Bad configuration
#endif
......@@ -67,7 +69,9 @@ int su_init(void)
{
su_home_threadsafe(NULL);
#if HAVE_SIGPIPE
signal(SIGPIPE, SIG_IGN); /* we want to get EPIPE instead */
#endif
su_log_init(su_log_default);
su_log_init(su_log_global);
......
......@@ -36,13 +36,6 @@
#include "config.h"
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <signal.h>
#include <assert.h>
struct pinger;
#define SU_ROOT_MAGIC_T struct pinger
#define SU_INTERNAL_P su_root_t *
......@@ -53,6 +46,12 @@ struct pinger;
#include "sofia-sip/su_log.h"
#include "sofia-sip/su_debug.h"
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <assert.h>
char const name[] = "su_test";
#if HAVE_FUNC
......@@ -410,14 +409,6 @@ init_ping(struct pinger *p, su_msg_r msg, su_sockaddr_t *arg)
}
}
static
RETSIGTYPE term(int n)
{
enter;
exit(1);
}
void
time_test(void)
{
......@@ -440,10 +431,12 @@ time_test(void)
printf("time_test: passed\n");
}
#if HAVE_ALARM
#if HAVE_SIGNAL
#include <unistd.h>
#include <signal.h>
#if HAVE_ALARM
static RETSIGTYPE sig_alarm(int s)
{
enter;
......@@ -456,6 +449,16 @@ static char const no_alarm[] = " [--no-alarm]";
static char const no_alarm[] = "";
#endif
static
RETSIGTYPE term(int n)
{
enter;
exit(1);
}
#endif
void
usage(int exitcode)
{
......@@ -519,11 +522,10 @@ int main(int argc, char *argv[])
}
}
signal(SIGTERM, term);
su_init(); atexit(su_deinit);
time_test();
#if HAVE_SIGNAL
signal(SIGTERM, term);
#if HAVE_ALARM
if (opt_alarm) {
......@@ -532,6 +534,10 @@ int main(int argc, char *argv[])
}
#endif
#endif
time_test();
root = su_root_create(NULL);
if (!root) perror("su_root_create"), exit(1);
......
......@@ -39,7 +39,6 @@
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <signal.h>
#include <assert.h>
......@@ -91,6 +90,10 @@ print_X(struct tester *x, su_timer_t *t1, struct timing *ti)
putchar('X'); fflush(stdout);
}
#if HAVE_SIGNAL
#include <signal.h>
su_msg_r intr_msg = SU_MSG_R_INIT;
static RETSIGTYPE intr_handler(int signum)
......@@ -103,6 +106,8 @@ static void test_break(struct tester *tester, su_msg_r msg, su_msg_arg_t *arg)
su_root_break(tester->root);
}
#endif
void
end_test(struct tester *tester, su_timer_t *t, struct timing *ti)
{
......@@ -182,6 +187,7 @@ int main(int argc, char *argv[])
tester->root = root = su_root_create(tester);
#if HAVE_SIGNAL
su_msg_create(intr_msg,
su_root_task(root),
su_root_task(root),
......@@ -189,9 +195,9 @@ int main(int argc, char *argv[])
signal(SIGINT, intr_handler);
#if HAVE_SIGPIPE
signal(SIGPIPE, intr_handler);
signal(SIGQUIT, intr_handler);
signal(SIGHUP, intr_handler);
#endif
#endif
t = su_timer_create(su_root_task(root), interval);
......@@ -217,7 +223,9 @@ int main(int argc, char *argv[])
su_root_run(root);
#if HAVE_SIGNAL
su_msg_destroy(intr_msg);
#endif
su_timer_destroy(t);
su_timer_destroy(t1);
......
......@@ -55,7 +55,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>
#include "tport_tls.h"
......@@ -162,9 +161,6 @@ int tls_init_context(tls_t *tls, tls_issues_t const *ti)
}
}
/* Avoid possible SIGPIPE when sending close_notify */
signal(SIGPIPE, SIG_IGN);
if (tls->bio_err == NULL)
tls->bio_err = BIO_new_fp(stderr, BIO_NOCLOSE);
......@@ -295,8 +291,6 @@ tls_t *tls_init_master(tls_issues_t *ti)
unsigned char sessionId[32] = "sofia/tls";
tls_t *tls;
signal(SIGPIPE, SIG_IGN); /* Ignore spurios SIGPIPE from OpenSSL */
tls_set_default(ti);
if (!(tls = tls_create(tls_master)))
......
......@@ -429,9 +429,10 @@ AC_SEARCH_LIBS(getipnodebyname, xnet socket nsl)
AC_SEARCH_LIBS(gethostbyname, xnet nsl)
AC_SEARCH_LIBS(getaddrinfo, xnet socket nsl)
AC_CHECK_FUNCS([gettimeofday strerror random initstate tcsetattr flock alarm \
AC_CHECK_FUNCS([gettimeofday strerror random initstate tcsetattr flock \
socketpair gethostname gethostbyname getipnodebyname \
poll epoll_create select if_nameindex \
signal alarm \
getaddrinfo getnameinfo freeaddrinfo gai_strerror getifaddrs \
getline getdelim getpass])
# getline getdelim getpass are _GNU_SOURCE stuff
......@@ -457,6 +458,14 @@ fi
SAC_REPLACE_FUNCS([memmem memccpy memspn memcspn strcasestr strtoull \
inet_ntop inet_pton])
if test $ac_cv_func_signal = yes ; then
AC_CHECK_DECL([SIGPIPE], [
AC_DEFINE([HAVE_SIGPIPE], 1, [Define to 1 if you have SIGPIPE])],,[
#include <signal.h>
])
dnl add SIGHUP SIGQUIT if needed
fi
# ===========================================================================
# Check how to implement su_port
# ===========================================================================
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment