version 1.15, 2000/12/07 10:04:56 |
version 1.16, 2000/12/22 04:06:37 |
|
|
/* -*- 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.15 2000/12/07 10:04:56 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() |
{ |
{ |
|
int mask = sigsetmask(sigmask(SIGUSR1)); |
fprintf(stderr, "signal received.\n"); |
fprintf(stderr, "signal received.\n"); |
signal(SIGUSR1, handler); |
exchange_ox_sync_ball(stack_oxfp); |
flag_sigusr1++; |
sigsetmask(mask); /* 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 92 int sm_receive_ox() |
|
|
|
int sm(OXFILE *oxfp) |
int sm(OXFILE *oxfp) |
{ |
{ |
int mask; |
int mask = siggetmask(); |
|
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(2, &fdmask, NULL, NULL, NULL) > 0) { |
if(flag_sigusr1) { |
sigsetmask(sigmask(SIGUSR1)); |
exchange_ox_sync_ball(oxfp); |
sm_receive_ox(); |
flag_sigusr1 = 0; |
|
} |
} |
|
sigsetmask(mask); /* unmasked. */ |
} |
} |
fprintf(stderr, "SM: socket(%d) is closed.\n", stack_oxfp->fd); |
fprintf(stderr, "SM: socket(%d) is closed.\n", stack_oxfp->fd); |
} |
} |