Cleanup ACE_HAS_PTHREAD_SIGMASK_PROTOTYPE, all platforms support it so far as I can...
[ACE_TAO.git] / ACE / apps / JAWS3 / small / SS_State_WRITE.cpp
blob71d8dd1e3dab8843c247fce228e99437e2836a9a
1 #include "ace/FILE_Connector.h"
2 #include "ace/FILE_Addr.h"
3 #include "ace/FILE_IO.h"
5 #include "jaws3/IO.h"
7 #include "SS_State_WRITE.h"
8 #include "SS_State_ERROR.h"
9 #include "SS_State_DONE.h"
10 #include "SS_Data.h"
12 int
13 TeraSS_State_WRITE::service (JAWS_Event_Completer *ec, void *data)
15 JAWS_Event_Result fake_bad_result (0, JAWS_Event_Result::JE_ERROR);
17 // Retrieve context
18 TeraSS_Data *tdata = (TeraSS_Data *) data;
20 ACE_FILE_Addr file_addr (tdata->mb ().rd_ptr ());
21 ACE_FILE_Connector file_connector;
23 if (file_connector.connect ( tdata->file_io ()
24 , file_addr
25 , 0
26 , ACE_Addr::sap_any
27 , 0
28 , O_RDONLY
29 ) < 0)
31 ec->output_complete (fake_bad_result, & tdata->file_io ());
32 return 0;
36 JAWS_IO::instance ()->transmit ( tdata->peer ().get_handle ()
37 , tdata->file_io ().get_handle ()
38 , ec
39 , & tdata->file_io ()
42 return 0;
45 JAWS_Protocol_State *
46 TeraSS_State_WRITE::transition ( const JAWS_Event_Result &result
47 , void *data
48 , void *act
51 // Clean up FILE.
53 ((ACE_FILE_IO *) act)->close ();
55 // In the WRITE state, move to DONE state if success, ERROR if error.
57 JAWS_Protocol_State *next_state = 0;
59 switch (result.status ())
61 case JAWS_Event_Result::JE_OK:
62 next_state = TeraSS_State_DONE::instance ();
63 break;
64 case JAWS_Event_Result::JE_ERROR:
65 next_state = TeraSS_State_ERROR::instance ();
66 break;
67 default:
68 // Just bail unceremoniously.
69 next_state = TeraSS_State_DONE::instance ();
70 break;
73 return next_state;