version 1.16, 2000/12/22 04:06:37 |
version 1.23, 2005/07/26 12:52:04 |
|
|
/* -*- mode: C; coding: euc-japan -*- */ |
/* -*- mode: C; coding: euc-japan -*- */ |
/* $OpenXM: OpenXM/src/ox_math/serv1.c,v 1.15 2000/12/07 10:04:56 ohara Exp $ */ |
/* $OpenXM: OpenXM/src/ox_math/serv1.c,v 1.22 2003/02/13 01:29:38 ohara Exp $ */ |
|
|
/* |
/* |
Copyright (C) Katsuyoshi OHARA, 2000. |
Copyright (C) Katsuyoshi OHARA, 2000. |
|
|
|
|
extern OXFILE *stack_oxfp; |
extern OXFILE *stack_oxfp; |
|
|
/* SM_control_reset_connection */ |
|
static void handler() |
|
{ |
|
int mask = sigsetmask(sigmask(SIGUSR1)); |
|
fprintf(stderr, "signal received.\n"); |
|
exchange_ox_sync_ball(stack_oxfp); |
|
sigsetmask(mask); /* unmasked. */ |
|
} |
|
|
|
static int exchange_ox_sync_ball(OXFILE *oxfp) |
static int exchange_ox_sync_ball(OXFILE *oxfp) |
{ |
{ |
int tag; |
int tag; |
|
ox_printf("exchanging OX_SYNC_BALL\n"); |
send_ox_tag(oxfp, OX_SYNC_BALL); |
send_ox_tag(oxfp, OX_SYNC_BALL); |
while((tag = receive_ox_tag(oxfp)) != OX_SYNC_BALL) { |
while((tag = receive_ox_tag(oxfp)) != OX_SYNC_BALL) { |
if (tag == OX_DATA) { |
if (tag == OX_DATA) { |
|
|
exit(0); |
exit(0); |
} |
} |
|
|
#define VERSION 0x11121400 |
/* (Heisei)15/02/01 */ |
#define ID_STRING "2000/11/29" |
#define VERSION "2003/02/01" |
|
|
int main() |
int main() |
{ |
{ |
OXFILE* sv; |
OXFILE* sv; |
|
|
|
ox_stderr_init(stderr); |
ml_init(); |
ml_init(); |
mathcap_init(VERSION, ID_STRING, "ox_math", NULL, NULL); |
mathcap_init(VERSION, "ox_math"); |
|
|
sv = oxf_open(3); |
sv = oxf_open(3); |
oxf_determine_byteorder_server(sv); |
oxf_determine_byteorder_server(sv); |
Line 84 int sm_receive_ox() |
|
Line 77 int sm_receive_ox() |
|
sm_run(code); |
sm_run(code); |
break; |
break; |
default: |
default: |
fprintf(stderr, "illeagal message? ox_tag = (%d)\n", tag); |
ox_printf("illeagal OX message(%d)\n", tag); |
break; |
break; |
} |
} |
return 1; |
return 1; |
Line 92 int sm_receive_ox() |
|
Line 85 int sm_receive_ox() |
|
|
|
int sm(OXFILE *oxfp) |
int sm(OXFILE *oxfp) |
{ |
{ |
int mask = siggetmask(); |
int i=0; |
fd_set fdmask; |
fd_set fdmask; |
stack_oxfp = oxfp; |
stack_oxfp = oxfp; |
stack_extend(); |
stack_extend(); |
signal(SIGUSR1, handler); |
sm_siginit(); |
|
|
FD_ZERO(&fdmask); |
FD_ZERO(&fdmask); |
FD_SET(oxf_fileno(oxfp), &fdmask); |
FD_SET(oxf_fileno(oxfp), &fdmask); |
|
|
while(1) { |
for (i=0; ; i++) { |
if (select(2, &fdmask, NULL, NULL, NULL) > 0) { |
sm_sigunmask(); |
sigsetmask(sigmask(SIGUSR1)); |
ox_printf("phase%d: select\n",i); |
|
if (select(5, &fdmask, NULL, NULL, NULL) > 0) { |
|
sm_sigmask(); |
|
ox_printf("phase%d: receiving\n",i); |
sm_receive_ox(); |
sm_receive_ox(); |
} |
} |
sigsetmask(mask); /* unmasked. */ |
sm_sigmask(); |
|
ox_printf("phase%d: clearing(%d)\n",i,sm_state_interrupting()); |
|
if (sm_state_interrupting()) { |
|
exchange_ox_sync_ball(stack_oxfp); |
|
sm_state_clear_interrupting(); |
|
} |
} |
} |
fprintf(stderr, "SM: socket(%d) is closed.\n", stack_oxfp->fd); |
ox_printf("ox_math::socket(%d) is closed.\n", stack_oxfp->fd); |
} |
} |