version 1.15, 2000/12/07 10:04:56 |
version 1.18, 2002/04/11 19:53:40 |
|
|
/* -*- mode: C; coding: euc-japan -*- */ |
/* -*- mode: C; coding: euc-japan -*- */ |
/* $OpenXM: OpenXM/src/ox_math/serv1.c,v 1.14 2000/12/03 22:09:34 ohara Exp $ */ |
/* $OpenXM: OpenXM/src/ox_math/serv1.c,v 1.17 2002/04/11 14:13:37 ohara Exp $ */ |
|
|
/* |
/* |
Copyright (C) Katsuyoshi OHARA, 2000. |
Copyright (C) Katsuyoshi OHARA, 2000. |
|
|
|
|
extern OXFILE *stack_oxfp; |
extern OXFILE *stack_oxfp; |
|
|
/* if in_critical equals to 1 then we do not permit an interrupt. */ |
|
static int flag_sigusr1 = 0; |
|
|
|
/* SM_control_reset_connection */ |
/* SM_control_reset_connection */ |
static void handler() |
static void handler() |
{ |
{ |
|
sigset_t newmask, oldmask; |
|
sigemptyset(&newmask); |
|
sigaddset(&newmask, SIGUSR1); |
|
sigprocmask(SIG_SETMASK, &newmask, &oldmask); |
fprintf(stderr, "signal received.\n"); |
fprintf(stderr, "signal received.\n"); |
signal(SIGUSR1, handler); |
exchange_ox_sync_ball(stack_oxfp); |
flag_sigusr1++; |
sigprocmask(SIG_SETMASK, &oldmask, NULL); /* unmasked. */ |
} |
} |
|
|
static int exchange_ox_sync_ball(OXFILE *oxfp) |
static int exchange_ox_sync_ball(OXFILE *oxfp) |
|
|
ml_init(); |
ml_init(); |
mathcap_init(VERSION, ID_STRING, "ox_math", NULL, NULL); |
mathcap_init(VERSION, ID_STRING, "ox_math", NULL, NULL); |
|
|
signal(SIGUSR1, handler); |
|
|
|
sv = oxf_open(3); |
sv = oxf_open(3); |
oxf_determine_byteorder_server(sv); |
oxf_determine_byteorder_server(sv); |
sm(sv); |
sm(sv); |
Line 96 int sm_receive_ox() |
|
Line 95 int sm_receive_ox() |
|
|
|
int sm(OXFILE *oxfp) |
int sm(OXFILE *oxfp) |
{ |
{ |
int mask; |
fd_set fdmask; |
stack_oxfp = oxfp; |
stack_oxfp = oxfp; |
stack_extend(); |
stack_extend(); |
|
signal(SIGUSR1, handler); |
|
|
mask = sigsetmask(sigmask(SIGUSR1)); |
FD_ZERO(&fdmask); |
while(sm_receive_ox()) { |
FD_SET(oxf_fileno(oxfp), &fdmask); |
sigsetmask(mask); |
|
usleep(1); |
while(1) { |
sigsetmask(sigmask(SIGUSR1)); |
if (select(5, &fdmask, NULL, NULL, NULL) > 0) { |
if(flag_sigusr1) { |
sigset_t newmask, oldmask; |
exchange_ox_sync_ball(oxfp); |
sigemptyset(&newmask); |
flag_sigusr1 = 0; |
sigaddset(&newmask, SIGUSR1); |
|
sigprocmask(SIG_SETMASK, &newmask, &oldmask); |
|
sm_receive_ox(); |
|
sigprocmask(SIG_SETMASK, &oldmask, NULL); /* unmasked. */ |
} |
} |
} |
} |
fprintf(stderr, "SM: socket(%d) is closed.\n", stack_oxfp->fd); |
fprintf(stderr, "SM: socket(%d) is closed.\n", stack_oxfp->fd); |