@@ -27,9 +27,10 @@ int client_read(struct connection *client, int read_socket)
2727 int status = CORVUS_OK , limit = 16 ;
2828
2929 if (!STAILQ_EMPTY (& client -> info -> cmd_queue )
30- && STAILQ_FIRST (& client -> info -> cmd_queue )-> parse_done ) {
31- buf = conn_get_buf (client );
32- return client_trigger_event (client , buf );
30+ && STAILQ_FIRST (& client -> info -> cmd_queue )-> parse_done )
31+ {
32+ event_reregister (& client -> ctx -> loop , client , E_WRITABLE );
33+ return CORVUS_OK ;
3334 }
3435
3536 do {
@@ -80,6 +81,7 @@ void client_make_iov(struct conn_info *info)
8081
8182int client_write (struct connection * client )
8283{
84+ struct context * ctx = client -> ctx ;
8385 struct conn_info * info = client -> info ;
8486
8587 if (!STAILQ_EMPTY (& info -> cmd_queue )) {
@@ -101,8 +103,16 @@ int client_write(struct connection *client)
101103
102104 if (info -> iov .cursor >= info -> iov .len ) {
103105 cmd_iov_reset (& info -> iov );
104- }
105- if (conn_register (client ) == CORVUS_ERR ) {
106+ if (event_reregister (& ctx -> loop , client , E_READABLE ) == CORVUS_ERR ) {
107+ LOG (ERROR , "client_write: fail to reregister client %d" , client -> fd );
108+ return CORVUS_ERR ;
109+ }
110+ if (client_trigger_event (client , conn_get_buf (client )) == CORVUS_ERR ) {
111+ LOG (ERROR , "client_write: fail to trigger event %d %d" ,
112+ client -> fd , client -> ev -> fd );
113+ return CORVUS_ERR ;
114+ }
115+ } else if (event_reregister (& ctx -> loop , client , E_WRITABLE ) == CORVUS_ERR ) {
106116 LOG (ERROR , "client_write: fail to reregister client %d" , client -> fd );
107117 return CORVUS_ERR ;
108118 }
0 commit comments