+ case MEMCACHED_BEHAVIOR_CORK:
+ {
+ memcached_server_write_instance_st instance;
+ bool action= set_flag(data);
+
+ if (action == false)
+ {
+ ptr->flags.cork= set_flag(false);
+ return MEMCACHED_SUCCESS;
+ }
+
+ instance= memcached_server_instance_fetch(ptr, 0);
+ if (! instance)
+ return MEMCACHED_NO_SERVERS;
+
+
+ /* We just try the first host, and if it is down we return zero */
+ memcached_return_t rc;
+ rc= memcached_connect(instance);
+ if (rc != MEMCACHED_SUCCESS)
+ {
+ return rc;
+ }
+
+ /* Now we test! */
+ memcached_ternary_t enabled;
+ enabled= test_cork(instance, true);
+
+ switch (enabled)
+ {
+ case MEM_FALSE:
+ return ptr->cached_errno ? MEMCACHED_ERRNO : MEMCACHED_FAILURE ;
+ case MEM_TRUE:
+ {
+ enabled= test_cork(instance, false);
+
+ if (enabled == false) // Possible bug in OS?
+ {
+ memcached_quit_server(instance, false); // We should reset everything on this error.
+ return MEMCACHED_ERRNO; // Errno will be true because we will have already set it.
+ }
+ ptr->flags.cork= true;
+ ptr->flags.tcp_nodelay= true;
+ memcached_quit(ptr); // We go on and reset the connections.
+ }
+ break;
+ case MEM_NOT:
+ default:
+ return MEMCACHED_NOT_SUPPORTED;
+ }
+ }
+ break;