STATUS CS_crashserver_set( i4 offset, i4 lsbuf, char *sbuf, i4 size, PTR object ) { i4 count; STATUS stat; stat = CSterminate(CS_CRASH, &count); if( E_CS0003_NOT_QUIESCENT == stat ) stat = OK; return( stat ); }
STATUS CS_shutserver_set(i4 offset, i4 lsbuf, char *sbuf, i4 size, PTR object) { STATUS stat; i4 count; stat = CSterminate(CS_CLOSE, &count); if (E_CS0003_NOT_QUIESCENT == stat) stat = OK; if (stat) { /* FIXME ERsend? */ /* "Server will stop. %d. sessions remaining" */ } return (stat); }
STATUS CS_stopserver_set(i4 offset, i4 lsbuf, char *sbuf, i4 size, PTR object) { STATUS stat; i4 count; stat = CSterminate(CS_KILL, &count); if (E_CS0003_NOT_QUIESCENT == stat) stat = OK; if (stat) { /* FIXME ERsend? */ /* "Server will stop. %d. sessions aborted", count */ } return (stat); }
STATUS CS_stopcond_set(i4 offset, i4 lsbuf, char *sbuf, i4 size, PTR object) { STATUS stat; i4 count; stat = CSterminate(CS_COND_CLOSE, &count); if (E_CS0003_NOT_QUIESCENT == stat) stat = OK; if (stat) { /* FIXME ERsend? */ /* "Error stopping server, %d. sessions remaining", count */ } return (stat); }
/* A philosopher thread function, called out of CSdispatch */ STATUS philosopher( i4 mode, MY_SCB *scb, i4 *next_mode) { i4 bites = 0; #ifdef EX_DEBUG EX_CONTEXT context; if (EXdeclare(ex_handler, &context) != OK) { /* some exception was raised */ Psem( &SIsem ); SIfprintf( stderr,"Error: unexpected exception in philosopher()..."); Vsem( &SIsem ); EXdelete(); return FAIL; } #endif switch( mode ) { case CS_INITIATE: /* A new philsopher is born */ scb->phil = Threads++; status[scb->phil] = mode; while( bites < NBITES ) { getsticks( scb->phil ); eats( scb->phil ); bites++; freesticks( scb->phil ); thinks( scb->phil ); } /* fall into: */ default: *next_mode = CS_TERMINATE; break; case CS_TERMINATE: if( Noisy ) { # ifdef EX_SIG_DEBUG signal(SIGUSR1, intfunc); if (scb->phil == 1) { SIfprintf(stderr, "Send a signal #%d to process #%d\n", SIGUSR1, getpid()); pause(); } # endif /* EX_SIG_DEBUG */ Psem( &SIsem ); SIfprintf(stderr, "%d (%s) dies, RIP.\n", scb->phil, Names[ scb->phil ] ); if ( status[scb->phil] == mode ) { SIfprintf(stderr, "Oops this philosopher is already dead?\n"); SIfprintf(stderr, "\t\t CS code is non-functional\n"); } Vsem( &SIsem ); } *next_mode = CS_TERMINATE; /* If no more threads, shutdown */ status[scb->phil] = mode; if( --Threads == 0 ) { /* Everyone else should be dead, no semaphore needed. */ SIflush( stderr ); CSterminate( CS_KILL, (i4 *)NULL ); } break; } #ifdef EX_DEBUG EXdelete(); #endif return( OK ); }
/*{ ** Name: sxf_call - The main SXF entry point. ** ** Description: ** The routine checks that the arguments to sxf_call look reasonable. ** The implementing function is then called and operation completion ** status is returned to the caller. ** ** Inputs: ** op_code The SXF operation code. ** rcb The SXF request control block for the operation. ** ** Outputs: ** Returns: ** DB_STATUS ** Exceptions: ** none ** ** Side Effects: ** none ** ** History: ** 9-July-1992 (markg) ** Initial creation. ** 03-sep-1992 (pholman) ** Give calls NULL functionlaity for initial integration ** 20-oct-1992 (markg) ** Updated to have entry points for all SXF operations. */ DB_STATUS sxf_call( SXF_OPERATION op_code, SXF_RCB *rcb) { DB_STATUS status = E_DB_OK; EX_CONTEXT context; i4 error; CLRDBERR(&rcb->sxf_error); /* Make a cursury check for bad parameters. */ if (op_code < SXF_MIN_OPCODE || op_code > SXF_MAX_OPCODE || rcb->sxf_cb_type != SXFRCB_CB || rcb->sxf_length != sizeof (SXF_RCB) || (Sxf_svcb == NULL && op_code != SXC_STARTUP)) { /* Figure out the error in more detail. */ if (op_code < SXF_MIN_OPCODE || op_code > SXF_MAX_OPCODE) SETDBERR(&rcb->sxf_error, 0, E_SX0001_BAD_OP_CODE); else if (rcb->sxf_cb_type != SXFRCB_CB) SETDBERR(&rcb->sxf_error, 0, E_SX0002_BAD_CB_TYPE); else if (rcb->sxf_length != sizeof (SXF_RCB)) { TRdisplay("Bad SXF CB length. Input length %d expected %d\n", rcb->sxf_length, sizeof(SXF_RCB)); SETDBERR(&rcb->sxf_error, 0, E_SX0003_BAD_CB_LENGTH); } else SETDBERR(&rcb->sxf_error, 0, E_SX000F_SXF_NOT_ACTIVE); return (E_DB_ERROR); } if (EXdeclare(ex_handler, &context) == OK && (Sxf_svcb == NULL || (Sxf_svcb->sxf_svcb_status & SXF_CHECK) == 0)) { switch (op_code) { /* Control operations. */ case SXC_STARTUP: status = sxc_startup(rcb); break; case SXC_SHUTDOWN: status = sxc_shutdown(rcb); break; case SXC_BGN_SESSION: status = sxc_bgn_session(rcb); break; case SXC_END_SESSION: status = sxc_end_session(rcb); break; case SXC_ALTER_SESSION: status = sxc_alter_session(rcb); break; case SXC_AUDIT_THREAD: status = sxac_audit_thread(rcb); break; case SXC_AUDIT_WRITER_THREAD: status = sxac_audit_writer_thread(rcb); break; /* Audit file oerations */ case SXA_OPEN: status = sxaf_open(rcb); break; case SXA_CLOSE: status = sxaf_close(rcb); break; /* Audit record operations */ case SXR_WRITE: status = sxar_write(rcb); break; case SXR_POSITION: status = sxar_position(rcb); break; case SXR_READ: status = sxar_read(rcb); break; case SXR_FLUSH: status = sxar_flush(rcb); break; /* Audit state operations */ case SXS_ALTER: status = sxas_alter(rcb); break; case SXS_SHOW: status = sxas_show(rcb); break; } EXdelete(); return (status); } /* ** If exception handler declares or the SXF_SVCB has already been ** marked inconsistent, this is a server fatal condition. In most ** cases it is sufficient to return a server fatal error, and let the ** caller handle the rest. ** ** However, if this is an audit record write operation we have to ** nuke the server ourselves. The reason for this is that if the ** client code does not handle the return status correctly the ** security of the system could be compromised. */ EXdelete(); if (op_code == SXR_WRITE) { _VOID_ ule_format(E_SX0005_INTERNAL_ERROR, NULL, ULE_LOG, NULL, NULL, 0L, NULL, &error, 0); _VOID_ ule_format(E_SX1048_SERVER_TERMINATE, NULL, ULE_LOG, NULL, NULL, 0L, NULL, &error, 0); _VOID_ CSterminate(CS_KILL, NULL); } SETDBERR(&rcb->sxf_error, 0, E_SX0005_INTERNAL_ERROR); return (E_DB_FATAL); }