|
发表于 2008-5-20 10:34:46
|
显示全部楼层
Line 21 Convert TPC_Logging_Handler into an active object. The newly spawned detached thread runs the following TPC_Logging_Handler::svc() hook method:- virtual int svc () {
- for (;;)
- switch (logging_handler_.log_record ()) {
- case -1: return -1; // Error.
- case 0: return 0; // Client closed connection.
- default: continue; // Default case.
- }
- /* NOTREACHED */
- return 0;
- }
- };
复制代码 This method focuses solely on reading and processing client log records. We break out of the for loop and return from the method when the log_record() method detects that its peer service handler has closed the connection or when an error occurs. Returning from the method causes the thread to exit, which in turn triggers ACE_Task::svc_run() to call the inherited ACE_Svc_Handler::close() method on the object. By default, this method closes the peer stream and deletes the service handler if it was allocated dynamically, as described in the table on page 210. Since the thread was spawned using the THR_DETACHED flag, there's no need to wait for it to exit.
你的代码有错误,对ACE理解还不够深刻,读书哦。svc中返回0,会导致调用handle_close()的。这是多调的一次。 |
|