problem with the way the config_string is parsed by memcached()

Bug #1031570 reported by Mikhail
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Fix Released
Brian Aker

Bug Description

I was trying to use UDP to communicate with the server and provided the following config_string.

const char *udpConfigString = "--SERVER=localhost:11211 --VERIFY-KEY --SUPPORT-CAS --USE-UDP";

The subsequent calls to memcached() and memcached_set() seem to succeed but server logs show that the opcode is garbage.

I looked through the code and it seems like the socket connection is setup as soon as the yacc parser reads --SERVER. Instead the entire config string should be parsed before the socket connection is established.

/* Line 1806 of yacc.c */
#line 230 "libmemcached/csl/parser.yy"
            if (memcached_failed(context->rc= memcached_server_add_with_weight(context->memc, (yyvsp[(2) - (4)].server).c_str, (yyvsp[(3) - (4)].number), (yyvsp[(4) - (4)].number))))
              char buffer[1024];
              snprintf(buffer, sizeof(buffer), "Failed to add server: %s:%u", (yyvsp[(2) - (4)].server).c_str, uint32_t((yyvsp[(3) - (4)].number)));
              parser_abort(context, buffer);

Here the call to memcached_server_add_with_weight will create the socket and assume TCP.

In the config string specify --USE-UDP before --SERVER
const char *udpConfigString = "--VERIFY-KEY --SUPPORT-CAS --USE-UDP --SERVER=localhost:11211";

Revision history for this message
Brian Aker (brianaker) wrote :

You are right. The behavior was changed a while ago to speed up connections,... side effect is that UDP will not be set quite correctly.

This is fixable by delaying the connection until after parsing like you suggest.

Brian Aker (brianaker)
Changed in libmemcached:
status: New → Confirmed
milestone: none → 1.0.11
Brian Aker (brianaker)
Changed in libmemcached:
status: Confirmed → Fix Committed
importance: Undecided → Medium
assignee: nobody → Brian Aker (brianaker)
Brian Aker (brianaker)
Changed in libmemcached:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.