[Groonga-commit] groonga/groonga [master] Fix terminating after an invalid command in client mode.

Back to archive index

null+****@clear***** null+****@clear*****
2012年 5月 31日 (木) 16:16:22 JST


Daijiro MORI	2012-05-31 16:16:22 +0900 (Thu, 31 May 2012)

  New Revision: 8478c13624d34300e284c213c7044bac5068743c

  Log:
    Fix terminating after an invalid command in client mode.
    
    refs #1305

  Modified files:
    lib/com.c

  Modified: lib/com.c (+5 -1)
===================================================================
--- lib/com.c    2012-05-31 15:53:04 +0900 (c65a53f)
+++ lib/com.c    2012-05-31 16:16:22 +0900 (318f611)
@@ -688,6 +688,7 @@ grn_rc
 grn_com_send(grn_ctx *ctx, grn_com *cs,
              grn_com_header *header, const char *body, uint32_t size, int flags)
 {
+  grn_rc rc = GRN_SUCCESS;
   size_t whole_size = sizeof(grn_com_header) + size;
   ssize_t ret;
   header->size = htonl(size);
@@ -721,18 +722,21 @@ grn_com_send(grn_ctx *ctx, grn_com *cs,
     msg_iov[1].iov_len = size;
     if ((ret = sendmsg(cs->fd, &msg, MSG_NOSIGNAL|flags)) == -1) {
       SERR("sendmsg");
+      rc = ctx->rc;
     }
 #endif /* WIN32 */
   } else {
     if ((ret = send(cs->fd, (const void *)header, whole_size, MSG_NOSIGNAL|flags)) == -1) {
       SERR("send");
+      rc = ctx->rc;
     }
   }
   if (ret != whole_size) {
     GRN_LOG(ctx, GRN_LOG_ERROR, "sendmsg(%d): %" GRN_FMT_LLD " < %" GRN_FMT_LLU,
             cs->fd, (long long int)ret, (unsigned long long int)whole_size);
+    rc = ctx->rc;
   }
-  return ctx->rc;
+  return rc;
 }
 
 #define RETRY_MAX 10




Groonga-commit メーリングリストの案内
Back to archive index