[Groonga-commit] groonga/groonga [master] gqtp: use network byte order for grn_rc in GQTP header

Back to archive index

Kouhei Sutou null+****@clear*****
Fri Nov 2 16:51:54 JST 2012


Kouhei Sutou	2012-11-02 16:51:54 +0900 (Fri, 02 Nov 2012)

  New Revision: 9e672619c5755aba23612d73ec30a912a5f3cc91
  https://github.com/groonga/groonga/commit/9e672619c5755aba23612d73ec30a912a5f3cc91

  Log:
    gqtp: use network byte order for grn_rc in GQTP header
    
    It breaks backward compatibility. It means that you can not connect to
    groonga >= 2.0.9 server with groonga <= 2.0.8 clients.
    
    TODO: We chose whether is this change reasonable or not. Using network
    byte order is a good manner for network protocols. But backward
    incompatibility is not a good manner for applications. If this change is
    not reasonable, we should revert it.

  Modified files:
    lib/com.c
    lib/ctx.c

  Modified: lib/com.c (+1 -1)
===================================================================
--- lib/com.c    2012-11-02 16:46:49 +0900 (318f611)
+++ lib/com.c    2012-11-02 16:51:54 +0900 (910577d)
@@ -208,7 +208,7 @@ grn_msg_send(grn_ctx *ctx, grn_obj *msg, int flags)
         header->keylen = 0;
         header->level = 0;
         header->flags = flags;
-        header->status = (uint16_t) ctx->rc;
+        header->status = htons((uint16_t)ctx->rc);
         header->opaque = 0;
         header->cas = 0;
         //todo : MSG_DONTWAIT

  Modified: lib/ctx.c (+1 -1)
===================================================================
--- lib/ctx.c    2012-11-02 16:46:49 +0900 (4177e80)
+++ lib/ctx.c    2012-11-02 16:51:54 +0900 (fe60632)
@@ -1533,7 +1533,7 @@ grn_ctx_recv(grn_ctx *ctx, char **str, unsigned int *str_len, int *flags)
           *flags = (header.flags & GRN_CTX_TAIL) ? 0 : GRN_CTX_MORE;
         }
         ctx->impl->output_type = header.qtype;
-        ctx->rc = (int16_t) header.status;
+        ctx->rc = (int16_t)ntohs(header.status);
         ctx->errbuf[0] = '\0';
         ctx->errline = 0;
         ctx->errfile = "";
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index