Merge lp:~flier-lu/libmemcached/win32-vs2008 into lp:~tangent-org/libmemcached/trunk

Proposed by flier
Status: Work in progress
Proposed branch: lp:~flier-lu/libmemcached/win32-vs2008
Merge into: lp:~tangent-org/libmemcached/trunk
Diff against target: 7279 lines (+4809/-598)
67 files modified
.bzrignore (+13/-0)
clients/memcapable.c (+103/-61)
clients/memcat.c (+7/-4)
clients/memcp.c (+10/-7)
clients/memdump.c (+5/-2)
clients/memerror.c (+4/-1)
clients/memflush.c (+4/-1)
clients/memrm.c (+4/-1)
clients/memstat.c (+13/-9)
clients/utilities.c (+241/-231)
clients/utilities.h (+5/-0)
libhashkit/common.h (+20/-0)
libhashkit/fnv.c (+8/-4)
libhashkit/hashkit.c (+7/-9)
libhashkit/visibility.h (+14/-4)
libmemcached/allocators.c (+30/-20)
libmemcached/allocators.h (+1/-1)
libmemcached/analyze.c (+3/-1)
libmemcached/auto.c (+14/-9)
libmemcached/behavior.c (+5/-4)
libmemcached/byteorder.c (+3/-1)
libmemcached/common.h (+14/-6)
libmemcached/connect.c (+11/-7)
libmemcached/delete.c (+16/-10)
libmemcached/do.c (+4/-2)
libmemcached/fetch.c (+2/-1)
libmemcached/flush.c (+6/-3)
libmemcached/flush_buffers.c (+2/-1)
libmemcached/get.c (+66/-52)
libmemcached/hash.c (+9/-3)
libmemcached/hosts.c (+6/-4)
libmemcached/io.c (+42/-26)
libmemcached/memcached.c (+19/-32)
libmemcached/memcached.h (+1/-7)
libmemcached/purge.c (+8/-6)
libmemcached/quit.c (+4/-1)
libmemcached/response.c (+13/-6)
libmemcached/sasl.c (+4/-0)
libmemcached/server.c (+12/-5)
libmemcached/stats.c (+17/-8)
libmemcached/storage.c (+33/-22)
libmemcached/types.h (+7/-0)
libmemcached/verbosity.c (+3/-1)
libmemcached/version.c (+13/-6)
libmemcached/visibility.h (+14/-4)
libmemcached/watchpoint.h (+3/-3)
poll/poll.c (+21/-12)
win32/common.vsprops (+25/-0)
win32/debug.vsprops (+12/-0)
win32/getopt.c (+1067/-0)
win32/getopt.h (+173/-0)
win32/inttypes.h (+13/-0)
win32/libmemcached.sln (+92/-0)
win32/libmemcached.vcproj (+618/-0)
win32/memcapable.vcproj (+205/-0)
win32/memcat.vcproj (+204/-0)
win32/memcp.vcproj (+206/-0)
win32/memdump.vcproj (+205/-0)
win32/memerror.vcproj (+205/-0)
win32/memflush.vcproj (+205/-0)
win32/memrm.vcproj (+205/-0)
win32/memslap.vcproj (+263/-0)
win32/memstat.vcproj (+205/-0)
win32/release.vsprops (+12/-0)
win32/stdbool.h (+6/-0)
win32/wrappers.c (+16/-0)
win32/wrappers.h (+8/-0)
To merge this branch: bzr merge lp:~flier-lu/libmemcached/win32-vs2008
Reviewer Review Type Date Requested Status
Libmemcached-developers Pending
Review via email: mp+45334@code.launchpad.net

Description of the change

Remove C99 syntax and add supports to Win32 with VS2008

To post a comment you must log in.
905. By flier

use pointer instead of reference to pass allocator

906. By flier

port libhashkit to win32

907. By flier

-h

908. By flier

port poll to win32

909. By flier

update solution

910. By flier

define LIBMEMCACHED_STATIC to support static link

911. By flier

use DLL mode by default

912. By flier

replace %zu instead of %lu

913. By flier

porting client

Unmerged revisions

913. By flier

porting client

912. By flier

replace %zu instead of %lu

911. By flier

use DLL mode by default

910. By flier

define LIBMEMCACHED_STATIC to support static link

909. By flier

update solution

908. By flier

port poll to win32

907. By flier

-h

906. By flier

port libhashkit to win32

905. By flier

use pointer instead of reference to pass allocator

904. By flier

Add VS2008 project

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file '.bzrignore'
--- .bzrignore 2010-09-14 07:55:39 +0000
+++ .bzrignore 2011-01-13 03:40:43 +0000
@@ -185,3 +185,16 @@
185tests/testplus185tests/testplus
186tests/testudp186tests/testudp
187unittests/unittests187unittests/unittests
188win32/Debug
189win32/Release
190win32/libmemcached.vcproj.WIN2003R2.flier.user
191win32/memcapable.vcproj.WIN2003R2.flier.user
192win32/memcat.vcproj.WIN2003R2.flier.user
193win32/memcp.vcproj.WIN2003R2.flier.user
194win32/memdump.vcproj.WIN2003R2.flier.user
195win32/memerror.vcproj.WIN2003R2.flier.user
196win32/memflush.vcproj.WIN2003R2.flier.user
197win32/memrm.vcproj.WIN2003R2.flier.user
198win32/memslap.vcproj.WIN2003R2.flier.user
199win32/memstat.vcproj.WIN2003R2.flier.user
200*.bak
188201
=== modified file 'clients/memcapable.c'
--- clients/memcapable.c 2010-10-28 22:21:05 +0000
+++ clients/memcapable.c 2011-01-13 03:40:43 +0000
@@ -11,11 +11,18 @@
1111
12/* -*- Mode: C; tab-width: 2; c-basic-offset: 2; indent-tabs-mode: nil -*- */12/* -*- Mode: C; tab-width: 2; c-basic-offset: 2; indent-tabs-mode: nil -*- */
13#undef NDEBUG13#undef NDEBUG
14
14#include "config.h"15#include "config.h"
15#include <pthread.h>16#ifdef WIN32
16#include <sys/types.h>17# define ETIMEDOUT WSAETIMEDOUT
17#include <fcntl.h>18#else
18#include <signal.h>19# include <pthread.h>
20# include <sys/types.h>
21# include <fcntl.h>
22# include <signal.h>
23# include <unistd.h>
24#endif
25
19#include <stdio.h>26#include <stdio.h>
20#include <stdlib.h>27#include <stdlib.h>
21#include <errno.h>28#include <errno.h>
@@ -23,7 +30,6 @@
23#include <string.h>30#include <string.h>
24#include <inttypes.h>31#include <inttypes.h>
25#include <stdbool.h>32#include <stdbool.h>
26#include <unistd.h>
27#include <ctype.h>33#include <ctype.h>
2834
29#include <libmemcached/memcached.h>35#include <libmemcached/memcached.h>
@@ -88,11 +94,13 @@
88static struct addrinfo *lookuphost(const char *hostname, const char *port)94static struct addrinfo *lookuphost(const char *hostname, const char *port)
89{95{
90 struct addrinfo *ai= 0;96 struct addrinfo *ai= 0;
91 struct addrinfo hints= {.ai_family=AF_UNSPEC,97 struct addrinfo hints;
92 .ai_protocol=IPPROTO_TCP,
93 .ai_socktype=SOCK_STREAM};
94 int error= getaddrinfo(hostname, port, &hints, &ai);98 int error= getaddrinfo(hostname, port, &hints, &ai);
9599
100 hints.ai_family=AF_UNSPEC;
101 hints.ai_protocol=IPPROTO_TCP;
102 hints.ai_socktype=SOCK_STREAM;
103
96 if (error != 0)104 if (error != 0)
97 {105 {
98 if (error != EAI_SYSTEM)106 if (error != EAI_SYSTEM)
@@ -187,13 +195,12 @@
187 ret= recv(fd, buf, len, 0);195 ret= recv(fd, buf, len, 0);
188196
189 if (ret == SOCKET_ERROR && get_socket_errno() == EWOULDBLOCK) {197 if (ret == SOCKET_ERROR && get_socket_errno() == EWOULDBLOCK) {
190 struct pollfd fds= {198 struct pollfd fds;
191 .events= direction,
192 .fd= fd
193 };
194
195 int err= poll(&fds, 1, timeout * 1000);199 int err= poll(&fds, 1, timeout * 1000);
196200
201 fds.events= direction;
202 fds.fd= fd;
203
197 if (err == 1)204 if (err == 1)
198 {205 {
199 if (direction == POLLOUT)206 if (direction == POLLOUT)
@@ -322,6 +329,8 @@
322 */329 */
323static enum test_return recv_packet(response *rsp)330static enum test_return recv_packet(response *rsp)
324{331{
332 size_t bodysz;
333
325 execute(retry_read(rsp, sizeof(protocol_binary_response_no_extras)));334 execute(retry_read(rsp, sizeof(protocol_binary_response_no_extras)));
326335
327 /* Fix the byte order in the packet header */336 /* Fix the byte order in the packet header */
@@ -334,7 +343,7 @@
334 rsp->plain.message.header.response.cas=343 rsp->plain.message.header.response.cas=
335 ntohll(rsp->plain.message.header.response.cas);344 ntohll(rsp->plain.message.header.response.cas);
336345
337 size_t bodysz= rsp->plain.message.header.response.bodylen;346 bodysz= rsp->plain.message.header.response.bodylen;
338 if (bodysz > 0)347 if (bodysz > 0)
339 execute(retry_read(rsp->bytes + sizeof (protocol_binary_response_no_extras), bodysz));348 execute(retry_read(rsp->bytes + sizeof (protocol_binary_response_no_extras), bodysz));
340349
@@ -362,6 +371,8 @@
362 uint32_t flags,371 uint32_t flags,
363 uint32_t exptime)372 uint32_t exptime)
364{373{
374 off_t key_offset;
375
365 /* all of the storage commands use the same command layout */376 /* all of the storage commands use the same command layout */
366 protocol_binary_request_set *request= &cmd->set;377 protocol_binary_request_set *request= &cmd->set;
367378
@@ -375,7 +386,7 @@
375 request->message.body.flags= flags;386 request->message.body.flags= flags;
376 request->message.body.expiration= exptime;387 request->message.body.expiration= exptime;
377388
378 off_t key_offset= sizeof (protocol_binary_request_no_extras) + 8;389 key_offset= sizeof (protocol_binary_request_no_extras) + 8;
379 memcpy(cmd->bytes + key_offset, key, keylen);390 memcpy(cmd->bytes + key_offset, key, keylen);
380 if (dta != NULL)391 if (dta != NULL)
381 memcpy(cmd->bytes + key_offset + keylen, dta, dtalen);392 memcpy(cmd->bytes + key_offset + keylen, dta, dtalen);
@@ -397,6 +408,8 @@
397 const void* dta,408 const void* dta,
398 size_t dtalen)409 size_t dtalen)
399{410{
411 off_t key_offset;
412
400 /* all of the storage commands use the same command layout */413 /* all of the storage commands use the same command layout */
401 memset(cmd, 0, sizeof (*cmd));414 memset(cmd, 0, sizeof (*cmd));
402 cmd->plain.message.header.request.magic= PROTOCOL_BINARY_REQ;415 cmd->plain.message.header.request.magic= PROTOCOL_BINARY_REQ;
@@ -405,7 +418,7 @@
405 cmd->plain.message.header.request.bodylen= (uint32_t)(keylen + dtalen);418 cmd->plain.message.header.request.bodylen= (uint32_t)(keylen + dtalen);
406 cmd->plain.message.header.request.opaque= 0xdeadbeef;419 cmd->plain.message.header.request.opaque= 0xdeadbeef;
407420
408 off_t key_offset= sizeof (protocol_binary_request_no_extras);421 key_offset= sizeof (protocol_binary_request_no_extras);
409422
410 if (key != NULL)423 if (key != NULL)
411 memcpy(cmd->bytes + key_offset, key, keylen);424 memcpy(cmd->bytes + key_offset, key, keylen);
@@ -454,6 +467,8 @@
454 uint64_t initial,467 uint64_t initial,
455 uint32_t exptime)468 uint32_t exptime)
456{469{
470 off_t key_offset;
471
457 memset(cmd, 0, sizeof (cmd->incr));472 memset(cmd, 0, sizeof (cmd->incr));
458 cmd->incr.message.header.request.magic= PROTOCOL_BINARY_REQ;473 cmd->incr.message.header.request.magic= PROTOCOL_BINARY_REQ;
459 cmd->incr.message.header.request.opcode= cc;474 cmd->incr.message.header.request.opcode= cc;
@@ -465,7 +480,7 @@
465 cmd->incr.message.body.initial= htonll(initial);480 cmd->incr.message.body.initial= htonll(initial);
466 cmd->incr.message.body.expiration= htonl(exptime);481 cmd->incr.message.body.expiration= htonl(exptime);
467482
468 off_t key_offset= sizeof (protocol_binary_request_no_extras) + 20;483 key_offset= sizeof (protocol_binary_request_no_extras) + 20;
469 memcpy(cmd->bytes + key_offset, key, keylen);484 memcpy(cmd->bytes + key_offset, key, keylen);
470}485}
471486
@@ -643,12 +658,13 @@
643{658{
644 command cmd;659 command cmd;
645 response rsp;660 response rsp;
661 int ii;
646662
647 uint64_t value= 0xdeadbeefdeadcafe;663 uint64_t value= 0xdeadbeefdeadcafe;
648 storage_command(&cmd, cc, key, strlen(key), &value, sizeof (value), 0, 0);664 storage_command(&cmd, cc, key, strlen(key), &value, sizeof (value), 0, 0);
649665
650 /* set should always work */666 /* set should always work */
651 for (int ii= 0; ii < 10; ii++)667 for (ii= 0; ii < 10; ii++)
652 {668 {
653 if (ii == 0)669 if (ii == 0)
654 execute(send_packet(&cmd));670 execute(send_packet(&cmd));
@@ -716,12 +732,13 @@
716{732{
717 command cmd;733 command cmd;
718 response rsp;734 response rsp;
735 int ii;
719 uint64_t value= 0xdeadbeefdeadcafe;736 uint64_t value= 0xdeadbeefdeadcafe;
720 storage_command(&cmd, cc, key, strlen(key), &value, sizeof (value), 0, 0);737 storage_command(&cmd, cc, key, strlen(key), &value, sizeof (value), 0, 0);
721738
722 /* first add should work, rest of them should fail (even with cas739 /* first add should work, rest of them should fail (even with cas
723 as wildcard */740 as wildcard */
724 for (int ii=0; ii < 10; ii++)741 for (ii=0; ii < 10; ii++)
725 {742 {
726 if (ii == 0)743 if (ii == 0)
727 execute(send_packet(&cmd));744 execute(send_packet(&cmd));
@@ -775,12 +792,13 @@
775{792{
776 command cmd;793 command cmd;
777 response rsp;794 response rsp;
795 int ii;
778 uint64_t value= 0xdeadbeefdeadcafe;796 uint64_t value= 0xdeadbeefdeadcafe;
779 storage_command(&cmd, cc, key, strlen(key), &value, sizeof (value), 0, 0);797 storage_command(&cmd, cc, key, strlen(key), &value, sizeof (value), 0, 0);
780798
781 /* first replace should fail, successive should succeed (when the799 /* first replace should fail, successive should succeed (when the
782 item is added! */800 item is added! */
783 for (int ii= 0; ii < 10; ii++)801 for (ii= 0; ii < 10; ii++)
784 {802 {
785 if (ii == 0)803 if (ii == 0)
786 execute(send_packet(&cmd));804 execute(send_packet(&cmd));
@@ -931,9 +949,9 @@
931{949{
932 command cmd;950 command cmd;
933 response rsp;951 response rsp;
952 uint64_t ii;
934 arithmetic_command(&cmd, cc, key, strlen(key), 1, 0, 0);953 arithmetic_command(&cmd, cc, key, strlen(key), 1, 0, 0);
935954
936 uint64_t ii;
937 for (ii= 0; ii < 10; ++ii)955 for (ii= 0; ii < 10; ++ii)
938 {956 {
939 if (ii == 0)957 if (ii == 0)
@@ -969,9 +987,9 @@
969{987{
970 command cmd;988 command cmd;
971 response rsp;989 response rsp;
990 int ii;
972 arithmetic_command(&cmd, cc, key, strlen(key), 1, 9, 0);991 arithmetic_command(&cmd, cc, key, strlen(key), 1, 9, 0);
973992
974 int ii;
975 for (ii= 9; ii > -1; --ii)993 for (ii= 9; ii > -1; --ii)
976 {994 {
977 if (ii == 9)995 if (ii == 9)
@@ -1038,8 +1056,9 @@
1038{1056{
1039 command cmd;1057 command cmd;
1040 response rsp;1058 response rsp;
1059 int ii;
10411060
1042 for (int ii= 0; ii < 2; ++ii)1061 for (ii= 0; ii < 2; ++ii)
1043 {1062 {
1044 execute(binary_set_item(key, key));1063 execute(binary_set_item(key, key));
1045 flush_command(&cmd, cc, 0, ii == 0);1064 flush_command(&cmd, cc, 0, ii == 0);
@@ -1200,6 +1219,8 @@
12001219
1201static enum test_return test_ascii_quit(void)1220static enum test_return test_ascii_quit(void)
1202{1221{
1222 char buffer[80];
1223
1203 /* Verify that quit handles unknown options */1224 /* Verify that quit handles unknown options */
1204 execute(send_string("quit foo bar\r\n"));1225 execute(send_string("quit foo bar\r\n"));
1205 execute(receive_error_response());1226 execute(receive_error_response());
@@ -1212,7 +1233,6 @@
1212 execute(send_string("quit\r\n"));1233 execute(send_string("quit\r\n"));
12131234
1214 /* Socket should be closed now, read should return 0 */1235 /* Socket should be closed now, read should return 0 */
1215 char buffer[80];
1216 verify(timeout_io_op(sock, POLLIN, buffer, sizeof(buffer)) == 0);1236 verify(timeout_io_op(sock, POLLIN, buffer, sizeof(buffer)) == 0);
1217 return TEST_PASS_RECONNECT;1237 return TEST_PASS_RECONNECT;
12181238
@@ -1220,6 +1240,8 @@
12201240
1221static enum test_return test_ascii_version(void)1241static enum test_return test_ascii_version(void)
1222{1242{
1243 char buffer[256];
1244
1223 /* Verify that version command handles unknown options */1245 /* Verify that version command handles unknown options */
1224 execute(send_string("version foo bar\r\n"));1246 execute(send_string("version foo bar\r\n"));
1225 execute(receive_error_response());1247 execute(receive_error_response());
@@ -1230,7 +1252,7 @@
12301252
1231 /* Verify that verify works */1253 /* Verify that verify works */
1232 execute(send_string("version\r\n"));1254 execute(send_string("version\r\n"));
1233 char buffer[256];1255
1234 execute(receive_line(buffer, sizeof(buffer)));1256 execute(receive_line(buffer, sizeof(buffer)));
1235 verify(strncmp(buffer, "VERSION ", 8) == 0);1257 verify(strncmp(buffer, "VERSION ", 8) == 0);
12361258
@@ -1318,18 +1340,20 @@
13181340
1319static enum test_return ascii_get_unknown_value(char **key, char **value, ssize_t *ndata)1341static enum test_return ascii_get_unknown_value(char **key, char **value, ssize_t *ndata)
1320{1342{
1343 char *end, *ptr;
1344 unsigned long val;
1321 char buffer[1024];1345 char buffer[1024];
13221346
1323 execute(receive_line(buffer, sizeof(buffer)));1347 execute(receive_line(buffer, sizeof(buffer)));
1324 verify(strncmp(buffer, "VALUE ", 6) == 0);1348 verify(strncmp(buffer, "VALUE ", 6) == 0);
1325 char *end= strchr(buffer + 6, ' ');1349 end= strchr(buffer + 6, ' ');
1326 verify(end != NULL);1350 verify(end != NULL);
1327 *end= '\0';1351 *end= '\0';
1328 *key= strdup(buffer + 6);1352 *key= strdup(buffer + 6);
1329 verify(*key != NULL);1353 verify(*key != NULL);
1330 char *ptr= end + 1;1354 ptr= end + 1;
13311355
1332 unsigned long val= strtoul(ptr, &end, 10); /* flags */1356 val= strtoul(ptr, &end, 10); /* flags */
1333 verify(ptr != end);1357 verify(ptr != end);
1334 verify(val == 0);1358 verify(val == 0);
1335 verify(end != NULL);1359 verify(end != NULL);
@@ -1353,6 +1377,8 @@
13531377
1354static enum test_return ascii_get_value(const char *key, const char *value)1378static enum test_return ascii_get_value(const char *key, const char *value)
1355{1379{
1380 char *ptr, *end;
1381 unsigned long val;
13561382
1357 char buffer[1024];1383 char buffer[1024];
1358 size_t datasize= strlen(value);1384 size_t datasize= strlen(value);
@@ -1361,10 +1387,9 @@
1361 execute(receive_line(buffer, sizeof(buffer)));1387 execute(receive_line(buffer, sizeof(buffer)));
1362 verify(strncmp(buffer, "VALUE ", 6) == 0);1388 verify(strncmp(buffer, "VALUE ", 6) == 0);
1363 verify(strncmp(buffer + 6, key, strlen(key)) == 0);1389 verify(strncmp(buffer + 6, key, strlen(key)) == 0);
1364 char *ptr= buffer + 6 + strlen(key) + 1;1390 ptr= buffer + 6 + strlen(key) + 1;
1365 char *end;
13661391
1367 unsigned long val= strtoul(ptr, &end, 10); /* flags */1392 val= strtoul(ptr, &end, 10); /* flags */
1368 verify(ptr != end);1393 verify(ptr != end);
1369 verify(val == 0);1394 verify(val == 0);
1370 verify(end != NULL);1395 verify(end != NULL);
@@ -1409,6 +1434,8 @@
1409static enum test_return ascii_gets_value(const char *key, const char *value,1434static enum test_return ascii_gets_value(const char *key, const char *value,
1410 unsigned long *cas)1435 unsigned long *cas)
1411{1436{
1437 char *ptr, *end;
1438 unsigned long val;
14121439
1413 char buffer[1024];1440 char buffer[1024];
1414 size_t datasize= strlen(value);1441 size_t datasize= strlen(value);
@@ -1417,10 +1444,9 @@
1417 execute(receive_line(buffer, sizeof(buffer)));1444 execute(receive_line(buffer, sizeof(buffer)));
1418 verify(strncmp(buffer, "VALUE ", 6) == 0);1445 verify(strncmp(buffer, "VALUE ", 6) == 0);
1419 verify(strncmp(buffer + 6, key, strlen(key)) == 0);1446 verify(strncmp(buffer + 6, key, strlen(key)) == 0);
1420 char *ptr= buffer + 6 + strlen(key) + 1;1447 ptr= buffer + 6 + strlen(key) + 1;
1421 char *end;1448
14221449 val= strtoul(ptr, &end, 10); /* flags */
1423 unsigned long val= strtoul(ptr, &end, 10); /* flags */
1424 verify(ptr != end);1450 verify(ptr != end);
1425 verify(val == 0);1451 verify(val == 0);
1426 verify(end != NULL);1452 verify(end != NULL);
@@ -1555,6 +1581,8 @@
15551581
1556static enum test_return test_ascii_delete_impl(const char *key, bool noreply)1582static enum test_return test_ascii_delete_impl(const char *key, bool noreply)
1557{1583{
1584 char buffer[1024];
1585
1558 execute(ascii_set_item(key, "value"));1586 execute(ascii_set_item(key, "value"));
15591587
1560 execute(send_string("delete\r\n"));1588 execute(send_string("delete\r\n"));
@@ -1562,8 +1590,7 @@
1562 /* BUG: the server accepts delete a b */1590 /* BUG: the server accepts delete a b */
1563 execute(send_string("delete a b c d e\r\n"));1591 execute(send_string("delete a b c d e\r\n"));
1564 execute(receive_error_response());1592 execute(receive_error_response());
15651593
1566 char buffer[1024];
1567 sprintf(buffer, "delete %s%s\r\n", key, noreply ? " noreply" : "");1594 sprintf(buffer, "delete %s%s\r\n", key, noreply ? " noreply" : "");
1568 execute(send_string(buffer));1595 execute(send_string(buffer));
15691596
@@ -1606,11 +1633,13 @@
16061633
1607static enum test_return test_ascii_gets(void)1634static enum test_return test_ascii_gets(void)
1608{1635{
1636 unsigned long cas;
1637
1609 execute(ascii_set_item("test_ascii_gets", "value"));1638 execute(ascii_set_item("test_ascii_gets", "value"));
16101639
1611 execute(send_string("gets\r\n"));1640 execute(send_string("gets\r\n"));
1612 execute(receive_error_response());1641 execute(receive_error_response());
1613 unsigned long cas;1642
1614 execute(ascii_gets_item("test_ascii_gets", "value", true, &cas));1643 execute(ascii_gets_item("test_ascii_gets", "value", true, &cas));
1615 execute(ascii_gets_item("test_ascii_gets_notfound", "value", false, &cas));1644 execute(ascii_gets_item("test_ascii_gets_notfound", "value", false, &cas));
16161645
@@ -1619,7 +1648,11 @@
16191648
1620static enum test_return test_ascii_mget(void)1649static enum test_return test_ascii_mget(void)
1621{1650{
1651 uint32_t x;
1622 const uint32_t nkeys= 5;1652 const uint32_t nkeys= 5;
1653 char *returned[5];
1654 char buffer[5];
1655
1623 const char * const keys[]= {1656 const char * const keys[]= {
1624 "test_ascii_mget1",1657 "test_ascii_mget1",
1625 "test_ascii_mget2",1658 "test_ascii_mget2",
@@ -1629,7 +1662,7 @@
1629 "test_ascii_mget6"1662 "test_ascii_mget6"
1630 };1663 };
16311664
1632 for (uint32_t x= 0; x < nkeys; ++x)1665 for (x= 0; x < nkeys; ++x)
1633 execute(ascii_set_item(keys[x], "value"));1666 execute(ascii_set_item(keys[x], "value"));
16341667
1635 /* Ask for a key that doesn't exist as well */1668 /* Ask for a key that doesn't exist as well */
@@ -1637,9 +1670,7 @@
1637 "test_ascii_mget4 test_ascii_mget5 "1670 "test_ascii_mget4 test_ascii_mget5 "
1638 "test_ascii_mget6\r\n"));1671 "test_ascii_mget6\r\n"));
16391672
1640 char *returned[nkeys];1673 for (x= 0; x < nkeys; ++x)
1641
1642 for (uint32_t x= 0; x < nkeys; ++x)
1643 {1674 {
1644 ssize_t nbytes = 0;1675 ssize_t nbytes = 0;
1645 char *v= NULL;1676 char *v= NULL;
@@ -1648,16 +1679,16 @@
1648 verify(memcmp(v, "value", 5) == 0);1679 verify(memcmp(v, "value", 5) == 0);
1649 free(v);1680 free(v);
1650 }1681 }
16511682
1652 char buffer[5];
1653 execute(retry_read(buffer, 5));1683 execute(retry_read(buffer, 5));
1654 verify(memcmp(buffer, "END\r\n", 5) == 0);1684 verify(memcmp(buffer, "END\r\n", 5) == 0);
16551685
1656 /* verify that we got all the keys we expected */1686 /* verify that we got all the keys we expected */
1657 for (uint32_t x= 0; x < nkeys; ++x)1687 for (x= 0; x < nkeys; ++x)
1658 {1688 {
1689 uint32_t y;
1659 bool found= false;1690 bool found= false;
1660 for (uint32_t y= 0; y < nkeys; ++y)1691 for (y= 0; y < nkeys; ++y)
1661 {1692 {
1662 if (strcmp(keys[x], returned[y]) == 0)1693 if (strcmp(keys[x], returned[y]) == 0)
1663 {1694 {
@@ -1668,7 +1699,7 @@
1668 verify(found);1699 verify(found);
1669 }1700 }
16701701
1671 for (uint32_t x= 0; x < nkeys; ++x)1702 for (x= 0; x < nkeys; ++x)
1672 free(returned[x]);1703 free(returned[x]);
16731704
1674 return TEST_PASS;1705 return TEST_PASS;
@@ -1676,11 +1707,12 @@
16761707
1677static enum test_return test_ascii_incr_impl(const char* key, bool noreply)1708static enum test_return test_ascii_incr_impl(const char* key, bool noreply)
1678{1709{
1710 int x;
1679 char cmd[300];1711 char cmd[300];
1680 sprintf(cmd, "incr %s 1%s\r\n", key, noreply ? " noreply" : "");1712 sprintf(cmd, "incr %s 1%s\r\n", key, noreply ? " noreply" : "");
16811713
1682 execute(ascii_set_item(key, "0"));1714 execute(ascii_set_item(key, "0"));
1683 for (int x= 1; x < 11; ++x)1715 for (x= 1; x < 11; ++x)
1684 {1716 {
1685 execute(send_string(cmd));1717 execute(send_string(cmd));
16861718
@@ -1688,9 +1720,10 @@
1688 execute(test_ascii_version());1720 execute(test_ascii_version());
1689 else1721 else
1690 {1722 {
1723 int val;
1691 char buffer[80];1724 char buffer[80];
1692 execute(receive_line(buffer, sizeof(buffer)));1725 execute(receive_line(buffer, sizeof(buffer)));
1693 int val= atoi(buffer);1726 val= atoi(buffer);
1694 verify(val == x);1727 verify(val == x);
1695 }1728 }
1696 }1729 }
@@ -1712,11 +1745,12 @@
17121745
1713static enum test_return test_ascii_decr_impl(const char* key, bool noreply)1746static enum test_return test_ascii_decr_impl(const char* key, bool noreply)
1714{1747{
1748 int x;
1715 char cmd[300];1749 char cmd[300];
1716 sprintf(cmd, "decr %s 1%s\r\n", key, noreply ? " noreply" : "");1750 sprintf(cmd, "decr %s 1%s\r\n", key, noreply ? " noreply" : "");
17171751
1718 execute(ascii_set_item(key, "9"));1752 execute(ascii_set_item(key, "9"));
1719 for (int x= 8; x > -1; --x)1753 for (x= 8; x > -1; --x)
1720 {1754 {
1721 execute(send_string(cmd));1755 execute(send_string(cmd));
17221756
@@ -1724,9 +1758,10 @@
1724 execute(test_ascii_version());1758 execute(test_ascii_version());
1725 else1759 else
1726 {1760 {
1761 int val;
1727 char buffer[80];1762 char buffer[80];
1728 execute(receive_line(buffer, sizeof(buffer)));1763 execute(receive_line(buffer, sizeof(buffer)));
1729 int val= atoi(buffer);1764 val= atoi(buffer);
1730 verify(val == x);1765 verify(val == x);
1731 }1766 }
1732 }1767 }
@@ -1801,6 +1836,7 @@
1801 bool noreply)1836 bool noreply)
1802{1837{
1803 const char *value;1838 const char *value;
1839 char cmd[400];
18041840
1805 if (append)1841 if (append)
1806 value="hello";1842 value="hello";
@@ -1813,8 +1849,7 @@
1813 value=" world";1849 value=" world";
1814 else1850 else
1815 value="hello";1851 value="hello";
18161852
1817 char cmd[400];
1818 sprintf(cmd, "%s %s 0 0 %u%s\r\n%s\r\n",1853 sprintf(cmd, "%s %s 0 0 %u%s\r\n%s\r\n",
1819 append ? "append" : "prepend",1854 append ? "append" : "prepend",
1820 key, (unsigned int)strlen(value), noreply ? " noreply" : "",1855 key, (unsigned int)strlen(value), noreply ? " noreply" : "",
@@ -1864,10 +1899,12 @@
18641899
1865static enum test_return test_ascii_stat(void)1900static enum test_return test_ascii_stat(void)
1866{1901{
1902 char buffer[1024];
1903
1867 execute(send_string("stats noreply\r\n"));1904 execute(send_string("stats noreply\r\n"));
1868 execute(receive_error_response());1905 execute(receive_error_response());
1869 execute(send_string("stats\r\n"));1906 execute(send_string("stats\r\n"));
1870 char buffer[1024];1907
1871 do {1908 do {
1872 execute(receive_line(buffer, sizeof(buffer)));1909 execute(receive_line(buffer, sizeof(buffer)));
1873 } while (strcmp(buffer, "END\r\n") != 0);1910 } while (strcmp(buffer, "END\r\n") != 0);
@@ -1948,7 +1985,7 @@
1948 int failed= 0;1985 int failed= 0;
1949 const char *hostname= "localhost";1986 const char *hostname= "localhost";
1950 const char *port= "11211";1987 const char *port= "11211";
1951 int cmd;1988 int cmd, ii;
1952 bool prompt= false;1989 bool prompt= false;
1953 const char *testname= NULL;1990 const char *testname= NULL;
19541991
@@ -2000,8 +2037,11 @@
2000 return 1;2037 return 1;
2001 }2038 }
20022039
2003 for (int ii= 0; testcases[ii].description != NULL; ++ii)2040 for (ii= 0; testcases[ii].description != NULL; ++ii)
2004 {2041 {
2042 bool reconnect= false;
2043 enum test_return ret;
2044
2005 if (testname != NULL && strcmp(testcases[ii].description, testname) != 0)2045 if (testname != NULL && strcmp(testcases[ii].description, testname) != 0)
2006 continue;2046 continue;
20072047
@@ -2011,8 +2051,10 @@
20112051
2012 if (prompt)2052 if (prompt)
2013 {2053 {
2054 char buffer[80] = {0};
2055
2014 fprintf(stdout, "\nPress <return> when you are ready? ");2056 fprintf(stdout, "\nPress <return> when you are ready? ");
2015 char buffer[80] = {0};2057
2016 if (fgets(buffer, sizeof(buffer), stdin) != NULL) {2058 if (fgets(buffer, sizeof(buffer), stdin) != NULL) {
2017 if (strncmp(buffer, "skip", 4) == 0)2059 if (strncmp(buffer, "skip", 4) == 0)
2018 {2060 {
@@ -2029,8 +2071,8 @@
2029 fflush(stdout);2071 fflush(stdout);
2030 }2072 }
20312073
2032 bool reconnect= false;2074 reconnect= false;
2033 enum test_return ret= testcases[ii].function();2075 ret= testcases[ii].function();
2034 if (ret == TEST_FAIL)2076 if (ret == TEST_FAIL)
2035 {2077 {
2036 reconnect= true;2078 reconnect= true;
20372079
=== modified file 'clients/memcat.c'
--- clients/memcat.c 2010-07-27 22:38:51 +0000
+++ clients/memcat.c 2011-01-13 03:40:43 +0000
@@ -11,10 +11,13 @@
1111
12#include "config.h"12#include "config.h"
1313
14#ifndef WIN32
15# include <unistd.h>
16#endif
17
14#include <stdio.h>18#include <stdio.h>
15#include <inttypes.h>19#include <inttypes.h>
16#include <string.h>20#include <string.h>
17#include <unistd.h>
18#include <getopt.h>21#include <getopt.h>
19#include <libmemcached/memcached.h>22#include <libmemcached/memcached.h>
2023
@@ -95,8 +98,8 @@
95 {98 {
96 if (opt_verbose)99 if (opt_verbose)
97 {100 {
98 printf("key: %s\nflags: %x\nlength: %zu\nvalue: ",101 printf("key: %s\nflags: %x\nlength: %lu\nvalue: ",
99 argv[optind], flags, string_length);102 argv[optind], flags, (unsigned long)string_length);
100 }103 }
101104
102 if (opt_file)105 if (opt_file)
@@ -115,7 +118,7 @@
115 written= fwrite(string, 1, string_length, fp);118 written= fwrite(string, 1, string_length, fp);
116 if (written != string_length) 119 if (written != string_length)
117 {120 {
118 fprintf(stderr, "error writing file (written %zu, should be %zu)\n", written, string_length);121 fprintf(stderr, "error writing file (written %lu, should be %lu)\n", (unsigned long) written, (unsigned long) string_length);
119 return_code= -1;122 return_code= -1;
120 break;123 break;
121 }124 }
122125
=== modified file 'clients/memcp.c'
--- clients/memcp.c 2010-07-27 22:38:51 +0000
+++ clients/memcp.c 2011-01-13 03:40:43 +0000
@@ -11,19 +11,22 @@
1111
12#include "config.h"12#include "config.h"
1313
14#ifndef WIN32
15# include <unistd.h>
16# include <sys/types.h>
17# include <sys/types.h>
18# include <strings.h>
19#endif
20
14#include <stdio.h>21#include <stdio.h>
15#include <stdlib.h>22#include <stdlib.h>
16#include <inttypes.h>23#include <inttypes.h>
17#include <unistd.h>
18#include <getopt.h>24#include <getopt.h>
19#include <sys/types.h>
20#include <sys/stat.h>
21#include <sys/types.h>
22#include <fcntl.h>25#include <fcntl.h>
23#include <errno.h>26#include <errno.h>
24#include <strings.h>
25#include <string.h>27#include <string.h>
26#include <sys/types.h>28#include <sys/types.h>
29#include <sys/stat.h>
27#include <stdlib.h>30#include <stdlib.h>
28#include <limits.h>31#include <limits.h>
2932
@@ -147,9 +150,9 @@
147 if (opt_verbose)150 if (opt_verbose)
148 {151 {
149 static const char *opstr[] = { "set", "add", "replace" };152 static const char *opstr[] = { "set", "add", "replace" };
150 printf("op: %s\nsource file: %s\nlength: %zu\n"153 printf("op: %s\nsource file: %s\nlength: %lu\n"
151 "key: %s\nflags: %x\nexpires: %llu\n",154 "key: %s\nflags: %x\nexpires: %llu\n",
152 opstr[opt_method - OPT_SET], argv[optind], (size_t)sbuf.st_size,155 opstr[opt_method - OPT_SET], argv[optind], (unsigned long)sbuf.st_size,
153 ptr, opt_flags, (unsigned long long)opt_expires);156 ptr, opt_flags, (unsigned long long)opt_expires);
154 }157 }
155158
156159
=== modified file 'clients/memdump.c'
--- clients/memdump.c 2010-06-29 06:39:40 +0000
+++ clients/memdump.c 2011-01-13 03:40:43 +0000
@@ -11,17 +11,20 @@
1111
12#include "config.h"12#include "config.h"
1313
14#ifndef WIN32
15# include <unistd.h>
16# include <strings.h>
17#endif
18
14#include <stdio.h>19#include <stdio.h>
15#include <stdlib.h>20#include <stdlib.h>
16#include <inttypes.h>21#include <inttypes.h>
17#include <unistd.h>
18#include <getopt.h>22#include <getopt.h>
19#include <sys/types.h>23#include <sys/types.h>
20#include <sys/stat.h>24#include <sys/stat.h>
21#include <sys/types.h>25#include <sys/types.h>
22#include <fcntl.h>26#include <fcntl.h>
23#include <errno.h>27#include <errno.h>
24#include <strings.h>
25#include <string.h>28#include <string.h>
2629
27#include <libmemcached/memcached.h>30#include <libmemcached/memcached.h>
2831
=== modified file 'clients/memerror.c'
--- clients/memerror.c 2010-06-29 06:39:40 +0000
+++ clients/memerror.c 2011-01-13 03:40:43 +0000
@@ -10,10 +10,13 @@
10 */10 */
11#include "config.h"11#include "config.h"
1212
13#ifndef WIN32
14# include <unistd.h>
15#endif
16
13#include <stdio.h>17#include <stdio.h>
14#include <inttypes.h>18#include <inttypes.h>
15#include <string.h>19#include <string.h>
16#include <unistd.h>
17#include <getopt.h>20#include <getopt.h>
18#include <stdlib.h>21#include <stdlib.h>
19#include <libmemcached/memcached.h>22#include <libmemcached/memcached.h>
2023
=== modified file 'clients/memflush.c'
--- clients/memflush.c 2010-06-29 06:39:40 +0000
+++ clients/memflush.c 2011-01-13 03:40:43 +0000
@@ -9,9 +9,12 @@
9 *9 *
10 */10 */
11#include "config.h"11#include "config.h"
12
13#ifndef WIN32
14# include <unistd.h>
15#endif
1216
13#include <stdio.h>17#include <stdio.h>
14#include <unistd.h>
15#include <string.h>18#include <string.h>
16#include <getopt.h>19#include <getopt.h>
17#include <libmemcached/memcached.h>20#include <libmemcached/memcached.h>
1821
=== modified file 'clients/memrm.c'
--- clients/memrm.c 2010-07-27 22:38:51 +0000
+++ clients/memrm.c 2011-01-13 03:40:43 +0000
@@ -10,8 +10,11 @@
10 */10 */
11#include "config.h"11#include "config.h"
1212
13#ifndef WIN32
14# include <unistd.h>
15#endif
16
13#include <stdio.h>17#include <stdio.h>
14#include <unistd.h>
15#include <getopt.h>18#include <getopt.h>
16#include <libmemcached/memcached.h>19#include <libmemcached/memcached.h>
17#include <string.h>20#include <string.h>
1821
=== modified file 'clients/memstat.c'
--- clients/memstat.c 2010-07-28 20:59:36 +0000
+++ clients/memstat.c 2011-01-13 03:40:43 +0000
@@ -13,6 +13,10 @@
13 */13 */
14#include "config.h"14#include "config.h"
1515
16#ifndef WIN32
17# include <sys/time.h>
18#endif
19
16#include <stdio.h>20#include <stdio.h>
17#include <sys/types.h>21#include <sys/types.h>
18#include <sys/stat.h>22#include <sys/stat.h>
@@ -20,7 +24,6 @@
20#include <fcntl.h>24#include <fcntl.h>
21#include <string.h>25#include <string.h>
22#include <getopt.h>26#include <getopt.h>
23#include <sys/time.h>
2427
25#include <libmemcached/memcached.h>28#include <libmemcached/memcached.h>
2629
@@ -158,9 +161,12 @@
158 else if (strcmp(analyze_mode, "latency") == 0)161 else if (strcmp(analyze_mode, "latency") == 0)
159 {162 {
160 memcached_st **servers;163 memcached_st **servers;
161 uint32_t flags, server_count= memcached_server_count(memc);164 uint32_t x, flags, server_count= memcached_server_count(memc);
162 uint32_t num_of_tests= 32;165 uint32_t num_of_tests= 32;
163 const char *test_key= "libmemcached_test_key";166 const char *test_key= "libmemcached_test_key";
167 struct timeval start_time, end_time;
168 uint32_t slowest_server= 0;
169 long elapsed_time, slowest_time= 0;
164170
165 servers= malloc(sizeof(memcached_st*) * server_count);171 servers= malloc(sizeof(memcached_st*) * server_count);
166 if (!servers)172 if (!servers)
@@ -169,7 +175,7 @@
169 return;175 return;
170 }176 }
171177
172 for (uint32_t x= 0; x < server_count; x++)178 for (x= 0; x < server_count; x++)
173 {179 {
174 memcached_server_instance_st instance=180 memcached_server_instance_st instance=
175 memcached_server_instance_by_position(memc, x);181 memcached_server_instance_by_position(memc, x);
@@ -192,17 +198,15 @@
192 }198 }
193199
194 printf("Network Latency Test:\n\n");200 printf("Network Latency Test:\n\n");
195 struct timeval start_time, end_time;
196 uint32_t slowest_server= 0;
197 long elapsed_time, slowest_time= 0;
198201
199 for (uint32_t x= 0; x < server_count; x++)202 for (x= 0; x < server_count; x++)
200 {203 {
204 uint32_t y;
201 memcached_server_instance_st instance=205 memcached_server_instance_st instance=
202 memcached_server_instance_by_position(memc, x);206 memcached_server_instance_by_position(memc, x);
203 gettimeofday(&start_time, NULL);207 gettimeofday(&start_time, NULL);
204208
205 for (uint32_t y= 0; y < num_of_tests; y++)209 for (y= 0; y < num_of_tests; y++)
206 {210 {
207 size_t vlen;211 size_t vlen;
208 char *val= memcached_get(servers[x], test_key, strlen(test_key),212 char *val= memcached_get(servers[x], test_key, strlen(test_key),
@@ -250,7 +254,7 @@
250 }254 }
251 printf("\n");255 printf("\n");
252256
253 for (uint32_t x= 0; x < server_count; x++)257 for (x= 0; x < server_count; x++)
254 memcached_free(servers[x]);258 memcached_free(servers[x]);
255259
256 free(servers);260 free(servers);
257261
=== modified file 'clients/utilities.c'
--- clients/utilities.c 2010-07-28 20:59:36 +0000
+++ clients/utilities.c 2011-01-13 03:40:43 +0000
@@ -1,231 +1,241 @@
1/* LibMemcached1/* LibMemcached
2 * Copyright (C) 2006-2009 Brian Aker2 * Copyright (C) 2006-2009 Brian Aker
3 * All rights reserved.3 * All rights reserved.
4 *4 *
5 * Use and distribution licensed under the BSD license. See5 * Use and distribution licensed under the BSD license. See
6 * the COPYING file in the parent directory for full text.6 * the COPYING file in the parent directory for full text.
7 *7 *
8 * Summary:8 * Summary:
9 *9 *
10 */10 */
11#include "config.h"11#include "config.h"
1212
13#include <stdio.h>13#include <stdio.h>
14#include <ctype.h>14#include <ctype.h>
15#include <string.h>15#include <string.h>
16#include "utilities.h"16#include "utilities.h"
1717
1818#ifdef WIN32
19long int timedif(struct timeval a, struct timeval b)19#include <assert.h>
20{20
21 long us, s;21long long strtoll(char const* s, char** sN, int base)
2222{
23 us = (int)(a.tv_usec - b.tv_usec);23 assert(sN == 0);
24 us /= 1000;24 assert(base == 10);
25 s = (int)(a.tv_sec - b.tv_sec);25 return _atoi64(s);
26 s *= 1000;26}
27 return s + us;27#endif
28}28
2929long int timedif(struct timeval a, struct timeval b)
30void version_command(const char *command_name)30{
31{31 long us, s;
32 printf("%s v%u.%u\n", command_name, 1U, 0U);32
33 exit(0);33 us = (int)(a.tv_usec - b.tv_usec);
34}34 us /= 1000;
3535 s = (int)(a.tv_sec - b.tv_sec);
36static const char *lookup_help(memcached_options option)36 s *= 1000;
37{37 return s + us;
38 switch (option)38}
39 {39
40 case OPT_SERVERS: return("List which servers you wish to connect to.");40void version_command(const char *command_name)
41 case OPT_VERSION: return("Display the version of the application and then exit.");41{
42 case OPT_HELP: return("Display this message and then exit.");42 printf("%s v%u.%u\n", command_name, 1U, 0U);
43 case OPT_VERBOSE: return("Give more details on the progression of the application.");43 exit(0);
44 case OPT_DEBUG: return("Provide output only useful for debugging.");44}
45 case OPT_FLAG: return("Provide flag information for storage operation.");45
46 case OPT_EXPIRE: return("Set the expire option for the object.");46static const char *lookup_help(memcached_options option)
47 case OPT_SET: return("Use set command with memcached when storing.");47{
48 case OPT_REPLACE: return("Use replace command with memcached when storing.");48 switch (option)
49 case OPT_ADD: return("Use add command with memcached when storing.");49 {
50 case OPT_SLAP_EXECUTE_NUMBER: return("Number of times to execute the given test.");50 case OPT_SERVERS: return("List which servers you wish to connect to.");
51 case OPT_SLAP_INITIAL_LOAD: return("Number of key pairs to load before executing tests.");51 case OPT_VERSION: return("Display the version of the application and then exit.");
52 case OPT_SLAP_TEST: return("Test to run (currently \"get\" or \"set\").");52 case OPT_HELP: return("Display this message and then exit.");
53 case OPT_SLAP_CONCURRENCY: return("Number of users to simulate with load.");53 case OPT_VERBOSE: return("Give more details on the progression of the application.");
54 case OPT_SLAP_NON_BLOCK: return("Set TCP up to use non-blocking IO.");54 case OPT_DEBUG: return("Provide output only useful for debugging.");
55 case OPT_SLAP_TCP_NODELAY: return("Set TCP socket up to use nodelay.");55 case OPT_FLAG: return("Provide flag information for storage operation.");
56 case OPT_FLUSH: return("Flush servers before running tests.");56 case OPT_EXPIRE: return("Set the expire option for the object.");
57 case OPT_HASH: return("Select hash type.");57 case OPT_SET: return("Use set command with memcached when storing.");
58 case OPT_BINARY: return("Switch to binary protocol.");58 case OPT_REPLACE: return("Use replace command with memcached when storing.");
59 case OPT_ANALYZE: return("Analyze the provided servers.");59 case OPT_ADD: return("Use add command with memcached when storing.");
60 case OPT_UDP: return("Use UDP protocol when communicating with server.");60 case OPT_SLAP_EXECUTE_NUMBER: return("Number of times to execute the given test.");
61 case OPT_USERNAME: return "Username to use for SASL authentication";61 case OPT_SLAP_INITIAL_LOAD: return("Number of key pairs to load before executing tests.");
62 case OPT_PASSWD: return "Password to use for SASL authentication";62 case OPT_SLAP_TEST: return("Test to run (currently \"get\" or \"set\").");
63 case OPT_FILE: return "Path to file in which to save result";63 case OPT_SLAP_CONCURRENCY: return("Number of users to simulate with load.");
64 case OPT_STAT_ARGS: return "Argument for statistics";64 case OPT_SLAP_NON_BLOCK: return("Set TCP up to use non-blocking IO.");
65 default: WATCHPOINT_ASSERT(0);65 case OPT_SLAP_TCP_NODELAY: return("Set TCP socket up to use nodelay.");
66 };66 case OPT_FLUSH: return("Flush servers before running tests.");
6767 case OPT_HASH: return("Select hash type.");
68 WATCHPOINT_ASSERT(0);68 case OPT_BINARY: return("Switch to binary protocol.");
69 return "forgot to document this function :)";69 case OPT_ANALYZE: return("Analyze the provided servers.");
70}70 case OPT_UDP: return("Use UDP protocol when communicating with server.");
7171 case OPT_USERNAME: return "Username to use for SASL authentication";
72void help_command(const char *command_name, const char *description,72 case OPT_PASSWD: return "Password to use for SASL authentication";
73 const struct option *long_options,73 case OPT_FILE: return "Path to file in which to save result";
74 memcached_programs_help_st *options __attribute__((unused)))74 case OPT_STAT_ARGS: return "Argument for statistics";
75{75 default: WATCHPOINT_ASSERT(0);
76 unsigned int x;76 };
7777
78 printf("%s v%u.%u\n\n", command_name, 1U, 0U);78 WATCHPOINT_ASSERT(0);
79 printf("\t%s\n\n", description);79 return "forgot to document this function :)";
80 printf("Current options. A '=' means the option takes a value.\n\n");80}
8181
82 for (x= 0; long_options[x].name; x++)82void help_command(const char *command_name, const char *description,
83 {83 const struct option *long_options,
84 const char *help_message;84 memcached_programs_help_st *options __attribute__((unused)))
8585{
86 printf("\t --%s%c\n", long_options[x].name,86 unsigned int x;
87 long_options[x].has_arg ? '=' : ' ');87
88 if ((help_message= lookup_help(long_options[x].val)))88 printf("%s v%u.%u\n\n", command_name, 1U, 0U);
89 printf("\t\t%s\n", help_message);89 printf("\t%s\n\n", description);
90 }90 printf("Current options. A '=' means the option takes a value.\n\n");
9191
92 printf("\n");92 for (x= 0; long_options[x].name; x++)
93 exit(0);93 {
94}94 const char *help_message;
9595
96void process_hash_option(memcached_st *memc, char *opt_hash)96 printf("\t --%s%c\n", long_options[x].name,
97{97 long_options[x].has_arg ? '=' : ' ');
98 uint64_t set;98 if ((help_message= lookup_help(long_options[x].val)))
99 memcached_return_t rc;99 printf("\t\t%s\n", help_message);
100100 }
101 if (opt_hash == NULL)101
102 return;102 printf("\n");
103103 exit(0);
104 set= MEMCACHED_HASH_DEFAULT; /* Just here to solve warning */104}
105 if (!strcasecmp(opt_hash, "CRC"))105
106 set= MEMCACHED_HASH_CRC;106void process_hash_option(memcached_st *memc, char *opt_hash)
107 else if (!strcasecmp(opt_hash, "FNV1_64"))107{
108 set= MEMCACHED_HASH_FNV1_64;108 uint64_t set;
109 else if (!strcasecmp(opt_hash, "FNV1A_64"))109 memcached_return_t rc;
110 set= MEMCACHED_HASH_FNV1A_64;110
111 else if (!strcasecmp(opt_hash, "FNV1_32"))111 if (opt_hash == NULL)
112 set= MEMCACHED_HASH_FNV1_32;112 return;
113 else if (!strcasecmp(opt_hash, "FNV1A_32"))113
114 set= MEMCACHED_HASH_FNV1A_32;114 set= MEMCACHED_HASH_DEFAULT; /* Just here to solve warning */
115 else115 if (!strcasecmp(opt_hash, "CRC"))
116 {116 set= MEMCACHED_HASH_CRC;
117 fprintf(stderr, "hash: type not recognized %s\n", opt_hash);117 else if (!strcasecmp(opt_hash, "FNV1_64"))
118 exit(1);118 set= MEMCACHED_HASH_FNV1_64;
119 }119 else if (!strcasecmp(opt_hash, "FNV1A_64"))
120120 set= MEMCACHED_HASH_FNV1A_64;
121 rc= memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_HASH, set);121 else if (!strcasecmp(opt_hash, "FNV1_32"))
122 if (rc != MEMCACHED_SUCCESS)122 set= MEMCACHED_HASH_FNV1_32;
123 {123 else if (!strcasecmp(opt_hash, "FNV1A_32"))
124 fprintf(stderr, "hash: memcache error %s\n", memcached_strerror(memc, rc));124 set= MEMCACHED_HASH_FNV1A_32;
125 exit(1);125 else
126 }126 {
127}127 fprintf(stderr, "hash: type not recognized %s\n", opt_hash);
128128 exit(1);
129#ifdef LIBMEMCACHED_WITH_SASL_SUPPORT129 }
130static char *username;130
131static char *passwd;131 rc= memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_HASH, set);
132132 if (rc != MEMCACHED_SUCCESS)
133static int get_username(void *context, int id, const char **result,133 {
134 unsigned int *len)134 fprintf(stderr, "hash: memcache error %s\n", memcached_strerror(memc, rc));
135{135 exit(1);
136 (void)context;136 }
137 if (!result || (id != SASL_CB_USER && id != SASL_CB_AUTHNAME))137}
138 return SASL_BADPARAM;138
139139#ifdef LIBMEMCACHED_WITH_SASL_SUPPORT
140 *result= username;140static char *username;
141 if (len)141static char *passwd;
142 *len= (username == NULL) ? 0 : (unsigned int)strlen(username);142
143143static int get_username(void *context, int id, const char **result,
144 return SASL_OK;144 unsigned int *len)
145}145{
146146 (void)context;
147static int get_password(sasl_conn_t *conn, void *context, int id,147 if (!result || (id != SASL_CB_USER && id != SASL_CB_AUTHNAME))
148 sasl_secret_t **psecret)148 return SASL_BADPARAM;
149{149
150 (void)context;150 *result= username;
151 static sasl_secret_t* x;151 if (len)
152152 *len= (username == NULL) ? 0 : (unsigned int)strlen(username);
153 if (!conn || ! psecret || id != SASL_CB_PASS)153
154 return SASL_BADPARAM;154 return SASL_OK;
155155}
156 if (passwd == NULL)156
157 {157static int get_password(sasl_conn_t *conn, void *context, int id,
158 *psecret= NULL;158 sasl_secret_t **psecret)
159 return SASL_OK;159{
160 }160 (void)context;
161161 static sasl_secret_t* x;
162 size_t len= strlen(passwd);162
163 x = realloc(x, sizeof(sasl_secret_t) + len);163 if (!conn || ! psecret || id != SASL_CB_PASS)
164 if (!x)164 return SASL_BADPARAM;
165 return SASL_NOMEM;165
166166 if (passwd == NULL)
167 x->len = len;167 {
168 strcpy((void *)x->data, passwd);168 *psecret= NULL;
169169 return SASL_OK;
170 *psecret = x;170 }
171 return SASL_OK;171
172}172 size_t len= strlen(passwd);
173173 x = realloc(x, sizeof(sasl_secret_t) + len);
174/* callbacks we support */174 if (!x)
175static sasl_callback_t sasl_callbacks[] = {175 return SASL_NOMEM;
176 {176
177 SASL_CB_USER, &get_username, NULL177 x->len = len;
178 }, {178 strcpy((void *)x->data, passwd);
179 SASL_CB_AUTHNAME, &get_username, NULL179
180 }, {180 *psecret = x;
181 SASL_CB_PASS, &get_password, NULL181 return SASL_OK;
182 }, {182}
183 SASL_CB_LIST_END, NULL, NULL183
184 }184/* callbacks we support */
185};185static sasl_callback_t sasl_callbacks[] = {
186#endif186 {
187187 SASL_CB_USER, &get_username, NULL
188bool initialize_sasl(memcached_st *memc, char *user, char *password)188 }, {
189{189 SASL_CB_AUTHNAME, &get_username, NULL
190#ifdef LIBMEMCACHED_WITH_SASL_SUPPORT190 }, {
191 if (user != NULL && password != NULL)191 SASL_CB_PASS, &get_password, NULL
192 {192 }, {
193 username= user;193 SASL_CB_LIST_END, NULL, NULL
194 passwd= password;194 }
195195};
196 if (sasl_client_init(NULL) != SASL_OK)196#endif
197 {197
198 fprintf(stderr, "Failed to initialize sasl library!\n");198bool initialize_sasl(memcached_st *memc, char *user, char *password)
199 return false;199{
200 }200#ifdef LIBMEMCACHED_WITH_SASL_SUPPORT
201 memcached_set_sasl_callbacks(memc, sasl_callbacks);201 if (user != NULL && password != NULL)
202 }202 {
203#else203 username= user;
204 (void)memc;204 passwd= password;
205 (void)user;205
206 (void)password;206 if (sasl_client_init(NULL) != SASL_OK)
207#endif207 {
208208 fprintf(stderr, "Failed to initialize sasl library!\n");
209 return true;209 return false;
210}210 }
211211 memcached_set_sasl_callbacks(memc, sasl_callbacks);
212void shutdown_sasl(void)212 }
213{213#else
214#ifdef LIBMEMCACHED_WITH_SASL_SUPPORT214 (void)memc;
215 if (username != NULL || passwd != NULL)215 (void)user;
216 sasl_done();216 (void)password;
217#endif217#endif
218}218
219219 return true;
220void initialize_sockets(void)220}
221{221
222 /* Define the function for all platforms to avoid #ifdefs in each program */222void shutdown_sasl(void)
223#ifdef WIN32223{
224 WSADATA wsaData;224#ifdef LIBMEMCACHED_WITH_SASL_SUPPORT
225 if (WSAStartup(MAKEWORD(2,0), &wsaData) != 0)225 if (username != NULL || passwd != NULL)
226 {226 sasl_done();
227 fprintf(stderr, "Socket Initialization Error. Program aborted\n");227#endif
228 exit(EXIT_FAILURE);228}
229 }229
230#endif230void initialize_sockets(void)
231}231{
232 /* Define the function for all platforms to avoid #ifdefs in each program */
233#ifdef WIN32
234 WSADATA wsaData;
235 if (WSAStartup(MAKEWORD(2,0), &wsaData) != 0)
236 {
237 fprintf(stderr, "Socket Initialization Error. Program aborted\n");
238 exit(EXIT_FAILURE);
239 }
240#endif
241}
232242
=== modified file 'clients/utilities.h'
--- clients/utilities.h 2010-07-27 22:38:51 +0000
+++ clients/utilities.h 2011-01-13 03:40:43 +0000
@@ -34,6 +34,11 @@
34#define OPTIONSTRING const char*34#define OPTIONSTRING const char*
35#endif35#endif
3636
37#ifdef WIN32
38# define strcasecmp strcmp
39long long strtoll(char const* s, char** sN, int base);
40#endif
41
37typedef struct memcached_programs_help_st memcached_programs_help_st;42typedef struct memcached_programs_help_st memcached_programs_help_st;
3843
39struct memcached_programs_help_st44struct memcached_programs_help_st
4045
=== modified file 'libhashkit/common.h'
--- libhashkit/common.h 2010-09-13 12:27:18 +0000
+++ libhashkit/common.h 2011-01-13 03:40:43 +0000
@@ -17,6 +17,26 @@
17#include <stdlib.h>17#include <stdlib.h>
18#include <math.h>18#include <math.h>
1919
20#ifdef WIN32
21
22#include <limits.h>
23#define UINT32_MAX UINT_MAX
24
25#define __CONCAT(x, y) (x##y)
26
27#define INT8_C(value) ((int8_t) value)
28#define UINT8_C(value) ((uint8_t) __CONCAT(value, U))
29#define INT16_C(value) value
30#define UINT16_C(value) __CONCAT(value, U)
31#define INT32_C(value) __CONCAT(value, L)
32#define UINT32_C(value) __CONCAT(value, UL)
33#define INT64_C(value) __CONCAT(value, LL)
34#define UINT64_C(value) __CONCAT(value, ULL)
35#define INTMAX_C(value) __CONCAT(value, LL)
36#define UINTMAX_C(value) __CONCAT(value, ULL)
37
38#endif
39
20#include "hashkit.h"40#include "hashkit.h"
2141
22#ifdef __cplusplus42#ifdef __cplusplus
2343
=== modified file 'libhashkit/fnv.c'
--- libhashkit/fnv.c 2010-01-19 23:39:13 +0000
+++ libhashkit/fnv.c 2011-01-13 03:40:43 +0000
@@ -18,8 +18,9 @@
18{18{
19 /* Thanks to pierre@demartines.com for the pointer */19 /* Thanks to pierre@demartines.com for the pointer */
20 uint64_t hash= FNV_64_INIT;20 uint64_t hash= FNV_64_INIT;
21 size_t x;
2122
22 for (size_t x= 0; x < key_length; x++)23 for (x= 0; x < key_length; x++)
23 {24 {
24 hash *= FNV_64_PRIME;25 hash *= FNV_64_PRIME;
25 hash ^= (uint64_t)key[x];26 hash ^= (uint64_t)key[x];
@@ -31,8 +32,9 @@
31uint32_t hashkit_fnv1a_64(const char *key, size_t key_length, void *context __attribute__((unused)))32uint32_t hashkit_fnv1a_64(const char *key, size_t key_length, void *context __attribute__((unused)))
32{33{
33 uint32_t hash= (uint32_t) FNV_64_INIT;34 uint32_t hash= (uint32_t) FNV_64_INIT;
35 size_t x;
3436
35 for (size_t x= 0; x < key_length; x++)37 for (x= 0; x < key_length; x++)
36 {38 {
37 uint32_t val= (uint32_t)key[x];39 uint32_t val= (uint32_t)key[x];
38 hash ^= val;40 hash ^= val;
@@ -45,8 +47,9 @@
45uint32_t hashkit_fnv1_32(const char *key, size_t key_length, void *context __attribute__((unused)))47uint32_t hashkit_fnv1_32(const char *key, size_t key_length, void *context __attribute__((unused)))
46{48{
47 uint32_t hash= FNV_32_INIT;49 uint32_t hash= FNV_32_INIT;
50 size_t x;
4851
49 for (size_t x= 0; x < key_length; x++)52 for (x= 0; x < key_length; x++)
50 {53 {
51 uint32_t val= (uint32_t)key[x];54 uint32_t val= (uint32_t)key[x];
52 hash *= FNV_32_PRIME;55 hash *= FNV_32_PRIME;
@@ -59,8 +62,9 @@
59uint32_t hashkit_fnv1a_32(const char *key, size_t key_length, void *context __attribute__((unused)))62uint32_t hashkit_fnv1a_32(const char *key, size_t key_length, void *context __attribute__((unused)))
60{63{
61 uint32_t hash= FNV_32_INIT;64 uint32_t hash= FNV_32_INIT;
65 size_t x;
6266
63 for (size_t x= 0; x < key_length; x++)67 for (x= 0; x < key_length; x++)
64 {68 {
65 uint32_t val= (uint32_t)key[x];69 uint32_t val= (uint32_t)key[x];
66 hash ^= val;70 hash ^= val;
6771
=== modified file 'libhashkit/hashkit.c'
--- libhashkit/hashkit.c 2010-01-22 19:04:16 +0000
+++ libhashkit/hashkit.c 2011-01-13 03:40:43 +0000
@@ -8,18 +8,16 @@
88
9#include "common.h"9#include "common.h"
1010
11static const hashkit_st global_default_hash= {11static hashkit_st global_default_hash;
12 .base_hash= {
13 .function= hashkit_one_at_a_time,
14 .context= NULL
15 },
16 .flags= {
17 .is_base_same_distributed= false,
18 }
19};
2012
21static inline bool _hashkit_init(hashkit_st *self)13static inline bool _hashkit_init(hashkit_st *self)
22{14{
15 memset(&global_default_hash, 0, sizeof(global_default_hash));
16
17 global_default_hash.base_hash.function = hashkit_one_at_a_time;
18 global_default_hash.base_hash.context = NULL;
19 global_default_hash.flags.is_base_same_distributed = false;
20
23 self->base_hash= global_default_hash.base_hash;21 self->base_hash= global_default_hash.base_hash;
24 self->distribution_hash= global_default_hash.base_hash;22 self->distribution_hash= global_default_hash.base_hash;
25 self->flags= global_default_hash.flags;23 self->flags= global_default_hash.flags;
2624
=== modified file 'libhashkit/visibility.h'
--- libhashkit/visibility.h 2009-12-17 17:28:30 +0000
+++ libhashkit/visibility.h 2011-01-13 03:40:43 +0000
@@ -32,16 +32,26 @@
32# define HASHKIT_API __global32# define HASHKIT_API __global
33# define HASHKIT_LOCAL __hidden33# define HASHKIT_LOCAL __hidden
34# elif defined(_MSC_VER)34# elif defined(_MSC_VER)
35# define HASHKIT_API extern __declspec(dllexport) 35# if defined(LIBMEMCACHED_STATIC)
36# define HASHKIT_LOCAL36# define HASHKIT_API
37# define HASHKIT_LOCAL
38# else
39# define HASHKIT_API extern __declspec(dllexport)
40# define HASHKIT_LOCAL
41# endif
37# else42# else
38# define HASHKIT_API43# define HASHKIT_API
39# define HASHKIT_LOCAL44# define HASHKIT_LOCAL
40# endif /* defined(HAVE_VISIBILITY) */45# endif /* defined(HAVE_VISIBILITY) */
41#else /* defined(BUILDING_HASHKIT) */46#else /* defined(BUILDING_HASHKIT) */
42# if defined(_MSC_VER)47# if defined(_MSC_VER)
43# define HASHKIT_API extern __declspec(dllimport) 48# if defined(LIBMEMCACHED_STATIC)
44# define HASHKIT_LOCAL49# define HASHKIT_API
50# define HASHKIT_LOCAL
51# else
52# define HASHKIT_API extern __declspec(dllimport)
53# define HASHKIT_LOCAL
54# endif
45# else55# else
46# define HASHKIT_API56# define HASHKIT_API
47# define HASHKIT_LOCAL57# define HASHKIT_LOCAL
4858
=== modified file 'libmemcached/allocators.c'
--- libmemcached/allocators.c 2010-01-18 22:58:20 +0000
+++ libmemcached/allocators.c 2011-01-13 03:40:43 +0000
@@ -23,7 +23,7 @@
2323
24void *_libmemcached_calloc(const memcached_st *ptr, size_t nelem, size_t size, void *context)24void *_libmemcached_calloc(const memcached_st *ptr, size_t nelem, size_t size, void *context)
25{25{
26 if (ptr->allocators.malloc != _libmemcached_malloc)26 if (ptr->allocators->malloc != _libmemcached_malloc)
27 {27 {
28 void *ret = _libmemcached_malloc(ptr, nelem * size, context);28 void *ret = _libmemcached_malloc(ptr, nelem * size, context);
29 if (ret != NULL) 29 if (ret != NULL)
@@ -35,16 +35,26 @@
35 return calloc(nelem, size);35 return calloc(nelem, size);
36}36}
3737
38static const struct _allocators_st global_default_allocator= {38struct _allocators_st *create_global_default_allocator()
39 .calloc= _libmemcached_calloc,
40 .context= NULL,
41 .free= _libmemcached_free,
42 .malloc= _libmemcached_malloc,
43 .realloc= _libmemcached_realloc
44};
45
46struct _allocators_st memcached_allocators_return_default(void)
47{39{
40 struct _allocators_st *allocator = (struct _allocators_st *) malloc(sizeof(struct _allocators_st));
41
42 allocator->calloc= _libmemcached_calloc;
43 allocator->context= NULL;
44 allocator->free= _libmemcached_free;
45 allocator->malloc= _libmemcached_malloc;
46 allocator->realloc= _libmemcached_realloc;
47
48 return allocator;
49}
50
51static struct _allocators_st *global_default_allocator = NULL;
52
53struct _allocators_st *memcached_allocators_return_default(void)
54{
55 if (global_default_allocator == NULL)
56 global_default_allocator = create_global_default_allocator();
57
48 return global_default_allocator;58 return global_default_allocator;
49}59}
5060
@@ -66,11 +76,11 @@
66 }76 }
67 else77 else
68 {78 {
69 ptr->allocators.malloc= mem_malloc;79 ptr->allocators->malloc= mem_malloc;
70 ptr->allocators.free= mem_free;80 ptr->allocators->free= mem_free;
71 ptr->allocators.realloc= mem_realloc;81 ptr->allocators->realloc= mem_realloc;
72 ptr->allocators.calloc= mem_calloc;82 ptr->allocators->calloc= mem_calloc;
73 ptr->allocators.context= context;83 ptr->allocators->context= context;
74 }84 }
7585
76 return MEMCACHED_SUCCESS;86 return MEMCACHED_SUCCESS;
@@ -78,7 +88,7 @@
7888
79void *memcached_get_memory_allocators_context(const memcached_st *ptr)89void *memcached_get_memory_allocators_context(const memcached_st *ptr)
80{90{
81 return ptr->allocators.context;91 return ptr->allocators->context;
82}92}
8393
84void memcached_get_memory_allocators(const memcached_st *ptr,94void memcached_get_memory_allocators(const memcached_st *ptr,
@@ -87,8 +97,8 @@
87 memcached_realloc_fn *mem_realloc,97 memcached_realloc_fn *mem_realloc,
88 memcached_calloc_fn *mem_calloc)98 memcached_calloc_fn *mem_calloc)
89{99{
90 *mem_malloc= ptr->allocators.malloc;100 *mem_malloc= ptr->allocators->malloc;
91 *mem_free= ptr->allocators.free;101 *mem_free= ptr->allocators->free;
92 *mem_realloc= ptr->allocators.realloc;102 *mem_realloc= ptr->allocators->realloc;
93 *mem_calloc= ptr->allocators.calloc;103 *mem_calloc= ptr->allocators->calloc;
94}104}
95105
=== modified file 'libmemcached/allocators.h'
--- libmemcached/allocators.h 2010-01-21 23:45:12 +0000
+++ libmemcached/allocators.h 2011-01-13 03:40:43 +0000
@@ -47,7 +47,7 @@
47void *_libmemcached_calloc(const memcached_st *ptr, size_t nelem, size_t size, void *context);47void *_libmemcached_calloc(const memcached_st *ptr, size_t nelem, size_t size, void *context);
4848
49LIBMEMCACHED_LOCAL49LIBMEMCACHED_LOCAL
50struct _allocators_st memcached_allocators_return_default(void);50struct _allocators_st *memcached_allocators_return_default(void);
5151
52#ifdef __cplusplus52#ifdef __cplusplus
53}53}
5454
=== modified file 'libmemcached/analyze.c'
--- libmemcached/analyze.c 2010-01-10 00:49:55 +0000
+++ libmemcached/analyze.c 2011-01-13 03:40:43 +0000
@@ -49,13 +49,15 @@
49 const uint64_t total_get_hits,49 const uint64_t total_get_hits,
50 const uint64_t total_get_cmds)50 const uint64_t total_get_cmds)
51{51{
52 double temp;
53
52 if (total_get_hits == 0 || total_get_cmds == 0)54 if (total_get_hits == 0 || total_get_cmds == 0)
53 {55 {
54 result->pool_hit_ratio= 0;56 result->pool_hit_ratio= 0;
55 return;57 return;
56 }58 }
5759
58 double temp= (double) (total_get_hits/total_get_cmds);60 temp = (double) (total_get_hits/total_get_cmds);
59 result->pool_hit_ratio= temp * 100;61 result->pool_hit_ratio= temp * 100;
60}62}
6163
6264
=== modified file 'libmemcached/auto.c'
--- libmemcached/auto.c 2010-09-13 12:26:17 +0000
+++ libmemcached/auto.c 2011-01-13 03:40:43 +0000
@@ -89,6 +89,11 @@
89{89{
90 uint32_t server_key;90 uint32_t server_key;
91 memcached_server_write_instance_st instance;91 memcached_server_write_instance_st instance;
92 protocol_binary_request_incr request;
93 memcached_return_t rc;
94
95 struct libmemcached_io_vector_st vector[3];
96
92 bool no_reply= ptr->flags.no_reply;97 bool no_reply= ptr->flags.no_reply;
9398
94 unlikely (memcached_server_count(ptr) == 0)99 unlikely (memcached_server_count(ptr) == 0)
@@ -103,8 +108,9 @@
103 cmd= PROTOCOL_BINARY_CMD_DECREMENTQ;108 cmd= PROTOCOL_BINARY_CMD_DECREMENTQ;
104 if(cmd == PROTOCOL_BINARY_CMD_INCREMENT)109 if(cmd == PROTOCOL_BINARY_CMD_INCREMENT)
105 cmd= PROTOCOL_BINARY_CMD_INCREMENTQ;110 cmd= PROTOCOL_BINARY_CMD_INCREMENTQ;
106 }111 }
107 protocol_binary_request_incr request= {.bytes= {0}};112
113 memset(&request, 0, sizeof(request));
108114
109 request.message.header.request.magic= PROTOCOL_BINARY_REQ;115 request.message.header.request.magic= PROTOCOL_BINARY_REQ;
110 request.message.header.request.opcode= cmd;116 request.message.header.request.opcode= cmd;
@@ -116,14 +122,13 @@
116 request.message.body.initial= htonll(initial);122 request.message.body.initial= htonll(initial);
117 request.message.body.expiration= htonl((uint32_t) expiration);123 request.message.body.expiration= htonl((uint32_t) expiration);
118124
119 struct libmemcached_io_vector_st vector[]=125 vector[0].length= sizeof(request.bytes);
120 {126 vector[0].buffer= request.bytes;
121 { .length= sizeof(request.bytes), .buffer= request.bytes },127 vector[1].length= ptr->prefix_key_length;
122 { .length= ptr->prefix_key_length, .buffer= ptr->prefix_key },128 vector[1].buffer= ptr->prefix_key;
123 { .length= key_length, .buffer= key }129 vector[2].length= key_length;
124 };130 vector[2].buffer= key;
125131
126 memcached_return_t rc;
127 if ((rc= memcached_vdo(instance, vector, 3, true)) != MEMCACHED_SUCCESS)132 if ((rc= memcached_vdo(instance, vector, 3, true)) != MEMCACHED_SUCCESS)
128 {133 {
129 memcached_io_reset(instance);134 memcached_io_reset(instance);
130135
=== modified file 'libmemcached/behavior.c'
--- libmemcached/behavior.c 2010-07-27 22:38:51 +0000
+++ libmemcached/behavior.c 2011-01-13 03:40:43 +0000
@@ -178,6 +178,9 @@
178 case MEMCACHED_BEHAVIOR_CORK:178 case MEMCACHED_BEHAVIOR_CORK:
179 {179 {
180 memcached_server_write_instance_st instance;180 memcached_server_write_instance_st instance;
181 memcached_return_t rc;
182 memcached_ternary_t enabled;
183
181 bool action= set_flag(data);184 bool action= set_flag(data);
182185
183 if (action == false)186 if (action == false)
@@ -191,16 +194,14 @@
191 return MEMCACHED_NO_SERVERS;194 return MEMCACHED_NO_SERVERS;
192195
193196
194 /* We just try the first host, and if it is down we return zero */197 /* We just try the first host, and if it is down we return zero */
195 memcached_return_t rc;
196 rc= memcached_connect(instance);198 rc= memcached_connect(instance);
197 if (rc != MEMCACHED_SUCCESS)199 if (rc != MEMCACHED_SUCCESS)
198 {200 {
199 return rc;201 return rc;
200 }202 }
201203
202 /* Now we test! */204 /* Now we test! */
203 memcached_ternary_t enabled;
204 enabled= test_cork(instance, true);205 enabled= test_cork(instance, true);
205206
206 switch (enabled)207 switch (enabled)
207208
=== modified file 'libmemcached/byteorder.c'
--- libmemcached/byteorder.c 2010-09-02 08:23:44 +0000
+++ libmemcached/byteorder.c 2011-01-13 03:40:43 +0000
@@ -19,7 +19,9 @@
19 /* Little endian, flip the bytes around until someone makes a faster/better19 /* Little endian, flip the bytes around until someone makes a faster/better
20 * way to do this. */20 * way to do this. */
21 uint64_t rv= 0;21 uint64_t rv= 0;
22 for (uint8_t x= 0; x < 8; x++)22 uint8_t x;
23
24 for (x= 0; x < 8; x++)
23 {25 {
24 rv= (rv << 8) | (in & 0xff);26 rv= (rv << 8) | (in & 0xff);
25 in >>= 8;27 in >>= 8;
2628
=== modified file 'libmemcached/common.h'
--- libmemcached/common.h 2010-07-27 22:38:51 +0000
+++ libmemcached/common.h 2011-01-13 03:40:43 +0000
@@ -21,10 +21,18 @@
21#include <stdio.h>21#include <stdio.h>
22#include <stdlib.h>22#include <stdlib.h>
23#include <string.h>23#include <string.h>
24#include <strings.h>24
25#ifdef WIN32
26# define snprintf _snprintf
27# define strtoull strtoul
28#else
29# include <strings.h>
30# include <unistd.h>
31#endif
32
25#include <ctype.h>33#include <ctype.h>
26#include <sys/types.h>34#include <sys/types.h>
27#include <unistd.h>35
28#include <limits.h>36#include <limits.h>
29#include <errno.h>37#include <errno.h>
30#include <fcntl.h>38#include <fcntl.h>
@@ -204,22 +212,22 @@
204212
205static inline void libmemcached_free(const memcached_st *ptr, void *mem)213static inline void libmemcached_free(const memcached_st *ptr, void *mem)
206{214{
207 ptr->allocators.free(ptr, mem, ptr->allocators.context);215 ptr->allocators->free(ptr, mem, ptr->allocators->context);
208}216}
209217
210static inline void *libmemcached_malloc(const memcached_st *ptr, const size_t size)218static inline void *libmemcached_malloc(const memcached_st *ptr, const size_t size)
211{219{
212 return ptr->allocators.malloc(ptr, size, ptr->allocators.context);220 return ptr->allocators->malloc(ptr, size, ptr->allocators->context);
213}221}
214222
215static inline void *libmemcached_realloc(const memcached_st *ptr, void *mem, const size_t size)223static inline void *libmemcached_realloc(const memcached_st *ptr, void *mem, const size_t size)
216{224{
217 return ptr->allocators.realloc(ptr, mem, size, ptr->allocators.context);225 return ptr->allocators->realloc(ptr, mem, size, ptr->allocators->context);
218}226}
219227
220static inline void *libmemcached_calloc(const memcached_st *ptr, size_t nelem, size_t size)228static inline void *libmemcached_calloc(const memcached_st *ptr, size_t nelem, size_t size)
221{229{
222 return ptr->allocators.calloc(ptr, nelem, size, ptr->allocators.context);230 return ptr->allocators->calloc(ptr, nelem, size, ptr->allocators->context);
223}231}
224232
225#ifdef __cplusplus233#ifdef __cplusplus
226234
=== modified file 'libmemcached/connect.c'
--- libmemcached/connect.c 2010-09-13 06:05:34 +0000
+++ libmemcached/connect.c 2011-01-13 03:40:43 +0000
@@ -10,22 +10,26 @@
10 */10 */
1111
12#include "common.h"12#include "common.h"
13#include <sys/time.h>13#ifndef WIN32
14# include <sys/time.h>
15#endif
14#include <time.h>16#include <time.h>
1517
16static memcached_return_t connect_poll(memcached_server_st *ptr)18static memcached_return_t connect_poll(memcached_server_st *ptr)
17{19{
20 int timeout;
21
22 int error;
23 size_t loop_max= 5;
24
18 struct pollfd fds[1];25 struct pollfd fds[1];
19 fds[0].fd = ptr->fd;26 fds[0].fd = ptr->fd;
20 fds[0].events = POLLOUT;27 fds[0].events = POLLOUT;
2128
22 int timeout= ptr->root->connect_timeout;29 timeout= ptr->root->connect_timeout;
23 if (ptr->root->flags.no_block == true)30 if (ptr->root->flags.no_block == true)
24 timeout= -1;31 timeout= -1;
2532
26 int error;
27 size_t loop_max= 5;
28
29 while (--loop_max) // Should only loop on cases of ERESTART or EINTR33 while (--loop_max) // Should only loop on cases of ERESTART or EINTR
30 {34 {
31 error= poll(fds, 1, timeout);35 error= poll(fds, 1, timeout);
@@ -371,7 +375,7 @@
371static memcached_return_t network_connect(memcached_server_st *ptr)375static memcached_return_t network_connect(memcached_server_st *ptr)
372{376{
373 bool timeout_error_occured= false;377 bool timeout_error_occured= false;
374378 struct addrinfo *use;
375379
376 WATCHPOINT_ASSERT(ptr->fd == INVALID_SOCKET);380 WATCHPOINT_ASSERT(ptr->fd == INVALID_SOCKET);
377 WATCHPOINT_ASSERT(ptr->cursor_active == 0);381 WATCHPOINT_ASSERT(ptr->cursor_active == 0);
@@ -386,7 +390,7 @@
386 ptr->options.sockaddr_inited= true;390 ptr->options.sockaddr_inited= true;
387 }391 }
388392
389 struct addrinfo *use= ptr->address_info;393 use= ptr->address_info;
390 /* Create the socket */394 /* Create the socket */
391 while (use != NULL)395 while (use != NULL)
392 {396 {
393397
=== modified file 'libmemcached/delete.c'
--- libmemcached/delete.c 2010-09-13 12:26:17 +0000
+++ libmemcached/delete.c 2011-01-13 03:40:43 +0000
@@ -25,6 +25,7 @@
25 char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE];25 char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE];
26 uint32_t server_key;26 uint32_t server_key;
27 memcached_server_write_instance_st instance;27 memcached_server_write_instance_st instance;
28 bool no_reply;
2829
29 LIBMEMCACHED_MEMCACHED_DELETE_START();30 LIBMEMCACHED_MEMCACHED_DELETE_START();
3031
@@ -41,7 +42,7 @@
4142
42 to_write= (ptr->flags.buffer_requests) ? false : true;43 to_write= (ptr->flags.buffer_requests) ? false : true;
4344
44 bool no_reply= (ptr->flags.no_reply);45 no_reply= (ptr->flags.no_reply);
4546
46 if (ptr->flags.binary_protocol)47 if (ptr->flags.binary_protocol)
47 {48 {
@@ -153,7 +154,12 @@
153 bool flush)154 bool flush)
154{155{
155 memcached_server_write_instance_st instance;156 memcached_server_write_instance_st instance;
156 protocol_binary_request_delete request= {.bytes= {0}};157 protocol_binary_request_delete request;
158 struct libmemcached_io_vector_st vector[3];
159 memcached_return_t rc;
160 uint32_t x;
161
162 memset(&request, 0, sizeof(request));
157163
158 instance= memcached_server_instance_fetch(ptr, server_key);164 instance= memcached_server_instance_fetch(ptr, server_key);
159165
@@ -175,14 +181,14 @@
175 memcached_io_write(instance, NULL, 0, true);181 memcached_io_write(instance, NULL, 0, true);
176 }182 }
177183
178 struct libmemcached_io_vector_st vector[]=184 vector[0].length= sizeof(request.bytes);
179 {185 vector[0].buffer= request.bytes;
180 { .length= sizeof(request.bytes), .buffer= request.bytes},186 vector[1].length= ptr->prefix_key_length;
181 { .length= ptr->prefix_key_length, .buffer= ptr->prefix_key },187 vector[1].buffer= ptr->prefix_key;
182 { .length= key_length, .buffer= key },188 vector[2].length= key_length;
183 };189 vector[2].buffer= key;
184190
185 memcached_return_t rc= MEMCACHED_SUCCESS;191 rc= MEMCACHED_SUCCESS;
186192
187 if ((rc= memcached_vdo(instance, vector, 3, flush)) != MEMCACHED_SUCCESS)193 if ((rc= memcached_vdo(instance, vector, 3, flush)) != MEMCACHED_SUCCESS)
188 {194 {
@@ -194,7 +200,7 @@
194 {200 {
195 request.message.header.request.opcode= PROTOCOL_BINARY_CMD_DELETEQ;201 request.message.header.request.opcode= PROTOCOL_BINARY_CMD_DELETEQ;
196202
197 for (uint32_t x= 0; x < ptr->number_of_replicas; ++x)203 for (x= 0; x < ptr->number_of_replicas; ++x)
198 {204 {
199 memcached_server_write_instance_st replica;205 memcached_server_write_instance_st replica;
200206
201207
=== modified file 'libmemcached/do.c'
--- libmemcached/do.c 2010-09-13 12:26:17 +0000
+++ libmemcached/do.c 2011-01-13 03:40:43 +0000
@@ -56,6 +56,8 @@
56{56{
57 memcached_return_t rc;57 memcached_return_t rc;
58 ssize_t sent_length;58 ssize_t sent_length;
59 size_t command_length;
60 uint32_t x;
5961
60 WATCHPOINT_ASSERT(count);62 WATCHPOINT_ASSERT(count);
61 WATCHPOINT_ASSERT(vector);63 WATCHPOINT_ASSERT(vector);
@@ -78,8 +80,8 @@
7880
79 sent_length= memcached_io_writev(ptr, vector, count, with_flush);81 sent_length= memcached_io_writev(ptr, vector, count, with_flush);
8082
81 size_t command_length= 0;83 command_length= 0;
82 for (uint32_t x= 0; x < count; ++x, vector++)84 for (x= 0; x < count; ++x, vector++)
83 {85 {
84 command_length+= vector->length;86 command_length+= vector->length;
85 }87 }
8688
=== modified file 'libmemcached/fetch.c'
--- libmemcached/fetch.c 2010-04-01 21:30:52 +0000
+++ libmemcached/fetch.c 2011-01-13 03:40:43 +0000
@@ -91,12 +91,13 @@
91{91{
92 memcached_result_st *result= &ptr->result;92 memcached_result_st *result= &ptr->result;
93 memcached_return_t rc= MEMCACHED_FAILURE;93 memcached_return_t rc= MEMCACHED_FAILURE;
94 uint32_t x;
9495
95 while ((result= memcached_fetch_result(ptr, result, &rc)) != NULL) 96 while ((result= memcached_fetch_result(ptr, result, &rc)) != NULL)
96 {97 {
97 if (rc == MEMCACHED_SUCCESS)98 if (rc == MEMCACHED_SUCCESS)
98 {99 {
99 for (uint32_t x= 0; x < number_of_callbacks; x++)100 for (x= 0; x < number_of_callbacks; x++)
100 {101 {
101 rc= (*callback[x])(ptr, result, context);102 rc= (*callback[x])(ptr, result, context);
102 if (rc != MEMCACHED_SUCCESS)103 if (rc != MEMCACHED_SUCCESS)
103104
=== modified file 'libmemcached/flush.c'
--- libmemcached/flush.c 2010-04-02 19:55:21 +0000
+++ libmemcached/flush.c 2011-01-13 03:40:43 +0000
@@ -55,7 +55,10 @@
55static memcached_return_t memcached_flush_binary(memcached_st *ptr, 55static memcached_return_t memcached_flush_binary(memcached_st *ptr,
56 time_t expiration)56 time_t expiration)
57{57{
58 protocol_binary_request_flush request= {.bytes= {0}};58 protocol_binary_request_flush request;
59 uint32_t x;
60
61 memset(&request, 0, sizeof(request));
5962
60 unlikely (memcached_server_count(ptr) == 0)63 unlikely (memcached_server_count(ptr) == 0)
61 return MEMCACHED_NO_SERVERS;64 return MEMCACHED_NO_SERVERS;
@@ -67,7 +70,7 @@
67 request.message.header.request.bodylen= htonl(request.message.header.request.extlen);70 request.message.header.request.bodylen= htonl(request.message.header.request.extlen);
68 request.message.body.expiration= htonl((uint32_t) expiration);71 request.message.body.expiration= htonl((uint32_t) expiration);
6972
70 for (uint32_t x= 0; x < memcached_server_count(ptr); x++)73 for (x= 0; x < memcached_server_count(ptr); x++)
71 {74 {
72 memcached_server_write_instance_st instance=75 memcached_server_write_instance_st instance=
73 memcached_server_instance_fetch(ptr, x);76 memcached_server_instance_fetch(ptr, x);
@@ -88,7 +91,7 @@
88 } 91 }
89 }92 }
9093
91 for (uint32_t x= 0; x < memcached_server_count(ptr); x++)94 for (x= 0; x < memcached_server_count(ptr); x++)
92 {95 {
93 memcached_server_write_instance_st instance=96 memcached_server_write_instance_st instance=
94 memcached_server_instance_fetch(ptr, x);97 memcached_server_instance_fetch(ptr, x);
9598
=== modified file 'libmemcached/flush_buffers.c'
--- libmemcached/flush_buffers.c 2010-02-13 02:23:49 +0000
+++ libmemcached/flush_buffers.c 2011-01-13 03:40:43 +0000
@@ -3,8 +3,9 @@
3memcached_return_t memcached_flush_buffers(memcached_st *memc)3memcached_return_t memcached_flush_buffers(memcached_st *memc)
4{4{
5 memcached_return_t ret= MEMCACHED_SUCCESS;5 memcached_return_t ret= MEMCACHED_SUCCESS;
6 uint32_t x;
67
7 for (uint32_t x= 0; x < memcached_server_count(memc); ++x)8 for (x= 0; x < memcached_server_count(memc); ++x)
8 {9 {
9 memcached_server_write_instance_st instance=10 memcached_server_write_instance_st instance=
10 memcached_server_instance_fetch(memc, x);11 memcached_server_instance_fetch(memc, x);
1112
=== modified file 'libmemcached/get.c'
--- libmemcached/get.c 2010-09-13 12:26:17 +0000
+++ libmemcached/get.c 2011-01-13 03:40:43 +0000
@@ -149,6 +149,8 @@
149 uint8_t get_command_length= 4;149 uint8_t get_command_length= 4;
150 unsigned int master_server_key= (unsigned int)-1; /* 0 is a valid server id! */150 unsigned int master_server_key= (unsigned int)-1; /* 0 is a valid server id! */
151 bool is_master_key_set= false;151 bool is_master_key_set= false;
152 uint32_t x;
153 struct libmemcached_io_vector_st vector[4];
152154
153 unlikely (ptr->flags.use_udp)155 unlikely (ptr->flags.use_udp)
154 return MEMCACHED_NOT_SUPPORTED;156 return MEMCACHED_NOT_SUPPORTED;
@@ -178,7 +180,7 @@
178180
179 It might be optimum to bounce the connection if count > some number.181 It might be optimum to bounce the connection if count > some number.
180 */182 */
181 for (uint32_t x= 0; x < memcached_server_count(ptr); x++)183 for (x= 0; x < memcached_server_count(ptr); x++)
182 {184 {
183 memcached_server_write_instance_st instance=185 memcached_server_write_instance_st instance=
184 memcached_server_instance_fetch(ptr, x);186 memcached_server_instance_fetch(ptr, x);
@@ -211,7 +213,7 @@
211 If a server fails we warn about errors and start all over with sending keys213 If a server fails we warn about errors and start all over with sending keys
212 to the server.214 to the server.
213 */215 */
214 for (uint32_t x= 0; x < number_of_keys; x++)216 for (x= 0; x < number_of_keys; x++)
215 {217 {
216 memcached_server_write_instance_st instance;218 memcached_server_write_instance_st instance;
217 uint32_t server_key;219 uint32_t server_key;
@@ -227,14 +229,14 @@
227229
228 instance= memcached_server_instance_fetch(ptr, server_key);230 instance= memcached_server_instance_fetch(ptr, server_key);
229231
230 struct libmemcached_io_vector_st vector[]=232 vector[0].length= get_command_length;
231 {233 vector[0].buffer= get_command;
232 { .length= get_command_length, .buffer= get_command },234 vector[1].length= ptr->prefix_key_length;
233 { .length= ptr->prefix_key_length, .buffer= ptr->prefix_key },235 vector[1].buffer= ptr->prefix_key;
234 { .length= key_length[x], .buffer= keys[x] },236 vector[2].length= key_length[x];
235 { .length= 1, .buffer= " " }237 vector[2].buffer= keys[x];
236 };238 vector[3].length= 1;
237239 vector[3].buffer= " ";
238240
239 if (memcached_server_response_count(instance) == 0)241 if (memcached_server_response_count(instance) == 0)
240 {242 {
@@ -266,7 +268,7 @@
266 /*268 /*
267 Should we muddle on if some servers are dead?269 Should we muddle on if some servers are dead?
268 */270 */
269 for (uint32_t x= 0; x < memcached_server_count(ptr); x++)271 for (x= 0; x < memcached_server_count(ptr); x++)
270 {272 {
271 memcached_server_write_instance_st instance=273 memcached_server_write_instance_st instance=
272 memcached_server_instance_fetch(ptr, x);274 memcached_server_instance_fetch(ptr, x);
@@ -319,16 +321,16 @@
319 void *context,321 void *context,
320 unsigned int number_of_callbacks)322 unsigned int number_of_callbacks)
321{323{
324 memcached_return_t rc;
325 memcached_callback_st *original_callbacks= ptr->callbacks;
326 memcached_callback_st cb;
327
322 if ((ptr->flags.binary_protocol) == 0)328 if ((ptr->flags.binary_protocol) == 0)
323 return MEMCACHED_NOT_SUPPORTED;329 return MEMCACHED_NOT_SUPPORTED;
324330
325 memcached_return_t rc;331 cb.callback= callback;
326 memcached_callback_st *original_callbacks= ptr->callbacks;332 cb.context= context;
327 memcached_callback_st cb= {333 cb.number_of_callback= number_of_callbacks;
328 .callback= callback,
329 .context= context,
330 .number_of_callback= number_of_callbacks
331 };
332334
333 ptr->callbacks= &cb;335 ptr->callbacks= &cb;
334 rc= memcached_mget_by_key(ptr, master_key, master_key_length, keys,336 rc= memcached_mget_by_key(ptr, master_key, master_key_length, keys,
@@ -345,6 +347,7 @@
345 size_t number_of_keys, bool mget_mode)347 size_t number_of_keys, bool mget_mode)
346{348{
347 memcached_return_t rc= MEMCACHED_NOTFOUND;349 memcached_return_t rc= MEMCACHED_NOTFOUND;
350 uint32_t x;
348351
349 int flush= number_of_keys == 1;352 int flush= number_of_keys == 1;
350353
@@ -352,10 +355,15 @@
352 If a server fails we warn about errors and start all over with sending keys355 If a server fails we warn about errors and start all over with sending keys
353 to the server.356 to the server.
354 */357 */
355 for (uint32_t x= 0; x < number_of_keys; ++x)358 for (x= 0; x < number_of_keys; ++x)
356 {359 {
357 uint32_t server_key;360 uint32_t server_key;
358 memcached_server_write_instance_st instance;361 memcached_server_write_instance_st instance;
362 protocol_binary_request_getk request;
363 memcached_return_t vk;
364 struct libmemcached_io_vector_st vector[3];
365
366 memset(&request, 0, sizeof(request));
359367
360 if (is_master_key_set)368 if (is_master_key_set)
361 {369 {
@@ -375,14 +383,12 @@
375 continue;383 continue;
376 }384 }
377385
378 protocol_binary_request_getk request= {.bytes= {0}};
379 request.message.header.request.magic= PROTOCOL_BINARY_REQ;386 request.message.header.request.magic= PROTOCOL_BINARY_REQ;
380 if (mget_mode)387 if (mget_mode)
381 request.message.header.request.opcode= PROTOCOL_BINARY_CMD_GETKQ;388 request.message.header.request.opcode= PROTOCOL_BINARY_CMD_GETKQ;
382 else389 else
383 request.message.header.request.opcode= PROTOCOL_BINARY_CMD_GETK;390 request.message.header.request.opcode= PROTOCOL_BINARY_CMD_GETK;
384391
385 memcached_return_t vk;
386 vk= memcached_validate_key_length(key_length[x],392 vk= memcached_validate_key_length(key_length[x],
387 ptr->flags.binary_protocol);393 ptr->flags.binary_protocol);
388 unlikely (vk != MEMCACHED_SUCCESS)394 unlikely (vk != MEMCACHED_SUCCESS)
@@ -399,12 +405,12 @@
399 request.message.header.request.datatype= PROTOCOL_BINARY_RAW_BYTES;405 request.message.header.request.datatype= PROTOCOL_BINARY_RAW_BYTES;
400 request.message.header.request.bodylen= htonl((uint32_t)( key_length[x] + ptr->prefix_key_length));406 request.message.header.request.bodylen= htonl((uint32_t)( key_length[x] + ptr->prefix_key_length));
401407
402 struct libmemcached_io_vector_st vector[]=408 vector[0].length= sizeof(request.bytes);
403 {409 vector[0].buffer= request.bytes;
404 { .length= sizeof(request.bytes), .buffer= request.bytes },410 vector[1].length= ptr->prefix_key_length;
405 { .length= ptr->prefix_key_length, .buffer= ptr->prefix_key },411 vector[1].buffer= ptr->prefix_key;
406 { .length= key_length[x], .buffer= keys[x] }412 vector[2].length= key_length[x];
407 };413 vector[2].buffer= keys[x];
408414
409 if (memcached_io_writev(instance, vector, 3, flush) == -1)415 if (memcached_io_writev(instance, vector, 3, flush) == -1)
410 {416 {
@@ -427,12 +433,16 @@
427 /*433 /*
428 * Send a noop command to flush the buffers434 * Send a noop command to flush the buffers
429 */435 */
430 protocol_binary_request_noop request= {.bytes= {0}};436 uint32_t x;
437 protocol_binary_request_noop request;
438
439 memset(&request, 0, sizeof(request));
440
431 request.message.header.request.magic= PROTOCOL_BINARY_REQ;441 request.message.header.request.magic= PROTOCOL_BINARY_REQ;
432 request.message.header.request.opcode= PROTOCOL_BINARY_CMD_NOOP;442 request.message.header.request.opcode= PROTOCOL_BINARY_CMD_NOOP;
433 request.message.header.request.datatype= PROTOCOL_BINARY_RAW_BYTES;443 request.message.header.request.datatype= PROTOCOL_BINARY_RAW_BYTES;
434444
435 for (uint32_t x= 0; x < memcached_server_count(ptr); ++x)445 for (x= 0; x < memcached_server_count(ptr); ++x)
436 {446 {
437 memcached_server_write_instance_st instance=447 memcached_server_write_instance_st instance=
438 memcached_server_instance_fetch(ptr, x);448 memcached_server_instance_fetch(ptr, x);
@@ -471,23 +481,30 @@
471 memcached_return_t rc= MEMCACHED_NOTFOUND;481 memcached_return_t rc= MEMCACHED_NOTFOUND;
472 uint32_t start= 0;482 uint32_t start= 0;
473 uint64_t randomize_read= memcached_behavior_get(ptr, MEMCACHED_BEHAVIOR_RANDOMIZE_REPLICA_READ);483 uint64_t randomize_read= memcached_behavior_get(ptr, MEMCACHED_BEHAVIOR_RANDOMIZE_REPLICA_READ);
484 uint32_t replica;
474485
475 if (randomize_read)486 if (randomize_read)
476 start= (uint32_t)random() % (uint32_t)(ptr->number_of_replicas + 1);487 start= (uint32_t)random() % (uint32_t)(ptr->number_of_replicas + 1);
477488
478 /* Loop for each replica */489 /* Loop for each replica */
479 for (uint32_t replica= 0; replica <= ptr->number_of_replicas; ++replica)490 for (replica= 0; replica <= ptr->number_of_replicas; ++replica)
480 {491 {
481 bool success= true;492 bool success= true;
482493 uint32_t x;
483 for (uint32_t x= 0; x < number_of_keys; ++x)494 protocol_binary_request_getk request;
495 struct libmemcached_io_vector_st vector[3];
496
497 memset(&request, 0, sizeof(request));
498
499 for (x= 0; x < number_of_keys; ++x)
484 {500 {
485 memcached_server_write_instance_st instance;501 memcached_server_write_instance_st instance;
502 uint32_t server;
486503
487 if (hash[x] == memcached_server_count(ptr))504 if (hash[x] == memcached_server_count(ptr))
488 continue; /* Already successfully sent */505 continue; /* Already successfully sent */
489506
490 uint32_t server= hash[x] + replica;507 server= hash[x] + replica;
491508
492 /* In case of randomized reads */509 /* In case of randomized reads */
493 if (randomize_read && ((server + start) <= (hash[x] + ptr->number_of_replicas)))510 if (randomize_read && ((server + start) <= (hash[x] + ptr->number_of_replicas)))
@@ -512,16 +529,12 @@
512 continue;529 continue;
513 }530 }
514 }531 }
515532
516 protocol_binary_request_getk request= {533 request.message.header.request.magic= PROTOCOL_BINARY_REQ;
517 .message.header.request= {534 request.message.header.request.opcode= PROTOCOL_BINARY_CMD_GETK;
518 .magic= PROTOCOL_BINARY_REQ,535 request.message.header.request.keylen= htons((uint16_t)(key_length[x] + ptr->prefix_key_length));
519 .opcode= PROTOCOL_BINARY_CMD_GETK,536 request.message.header.request.datatype= PROTOCOL_BINARY_RAW_BYTES;
520 .keylen= htons((uint16_t)(key_length[x] + ptr->prefix_key_length)),537 request.message.header.request.bodylen= htonl((uint32_t)(key_length[x] + ptr->prefix_key_length));
521 .datatype= PROTOCOL_BINARY_RAW_BYTES,
522 .bodylen= htonl((uint32_t)(key_length[x] + ptr->prefix_key_length))
523 }
524 };
525538
526 /*539 /*
527 * We need to disable buffering to actually know that the request was540 * We need to disable buffering to actually know that the request was
@@ -533,12 +546,12 @@
533 * that we might have processed some of the responses etc. For now,546 * that we might have processed some of the responses etc. For now,
534 * just make sure we work _correctly_547 * just make sure we work _correctly_
535 */548 */
536 struct libmemcached_io_vector_st vector[]=549 vector[0].length= sizeof(request.bytes);
537 {550 vector[0].buffer= request.bytes;
538 { .length= sizeof(request.bytes), .buffer= request.bytes },551 vector[1].length= ptr->prefix_key_length;
539 { .length= ptr->prefix_key_length, .buffer= ptr->prefix_key },552 vector[1].buffer= ptr->prefix_key;
540 { .length= key_length[x], .buffer= keys[x] }553 vector[2].length= key_length[x];
541 };554 vector[2].buffer= keys[x];
542555
543 if (memcached_io_writev(instance, vector, 3, true) == -1)556 if (memcached_io_writev(instance, vector, 3, true) == -1)
544 {557 {
@@ -578,6 +591,7 @@
578 {591 {
579 uint32_t* hash;592 uint32_t* hash;
580 bool* dead_servers;593 bool* dead_servers;
594 size_t x;
581595
582 hash= libmemcached_malloc(ptr, sizeof(uint32_t) * number_of_keys);596 hash= libmemcached_malloc(ptr, sizeof(uint32_t) * number_of_keys);
583 dead_servers= libmemcached_calloc(ptr, memcached_server_count(ptr), sizeof(bool));597 dead_servers= libmemcached_calloc(ptr, memcached_server_count(ptr), sizeof(bool));
@@ -591,14 +605,14 @@
591605
592 if (is_master_key_set)606 if (is_master_key_set)
593 {607 {
594 for (size_t x= 0; x < number_of_keys; x++)608 for (x= 0; x < number_of_keys; x++)
595 {609 {
596 hash[x]= master_server_key;610 hash[x]= master_server_key;
597 }611 }
598 }612 }
599 else613 else
600 {614 {
601 for (size_t x= 0; x < number_of_keys; x++)615 for (x= 0; x < number_of_keys; x++)
602 {616 {
603 hash[x]= memcached_generate_hash_with_redistribution(ptr, keys[x], key_length[x]);617 hash[x]= memcached_generate_hash_with_redistribution(ptr, keys[x], key_length[x]);
604 }618 }
605619
=== modified file 'libmemcached/hash.c'
--- libmemcached/hash.c 2010-03-02 22:16:10 +0000
+++ libmemcached/hash.c 2011-01-13 03:40:43 +0000
@@ -30,11 +30,12 @@
30 case MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA:30 case MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA:
31 case MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA_SPY:31 case MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA_SPY:
32 {32 {
33 memcached_continuum_item_st *begin, *end, *left, *right, *middle;
33 uint32_t num= ptr->continuum_points_counter;34 uint32_t num= ptr->continuum_points_counter;
34 WATCHPOINT_ASSERT(ptr->continuum);35 WATCHPOINT_ASSERT(ptr->continuum);
3536
36 hash= hash;37 hash= hash;
37 memcached_continuum_item_st *begin, *end, *left, *right, *middle;38
38 begin= left= ptr->continuum;39 begin= left= ptr->continuum;
39 end= right= ptr->continuum + num;40 end= right= ptr->continuum + num;
4041
@@ -75,7 +76,8 @@
75 if (ptr->flags.hash_with_prefix_key)76 if (ptr->flags.hash_with_prefix_key)
76 {77 {
77 size_t temp_length= ptr->prefix_key_length + key_length;78 size_t temp_length= ptr->prefix_key_length + key_length;
78 char temp[temp_length];79 char *temp = (char *) malloc(temp_length);
80 uint32_t hash;
7981
80 if (temp_length > MEMCACHED_MAX_KEY -1)82 if (temp_length > MEMCACHED_MAX_KEY -1)
81 return 0;83 return 0;
@@ -83,7 +85,11 @@
83 strncpy(temp, ptr->prefix_key, ptr->prefix_key_length);85 strncpy(temp, ptr->prefix_key, ptr->prefix_key_length);
84 strncpy(temp + ptr->prefix_key_length, key, key_length);86 strncpy(temp + ptr->prefix_key_length, key, key_length);
8587
86 return generate_hash(ptr, temp, temp_length);88 hash = generate_hash(ptr, temp, temp_length);
89
90 free(temp);
91
92 return hash;
87 }93 }
88 else94 else
89 {95 {
9096
=== modified file 'libmemcached/hosts.c'
--- libmemcached/hosts.c 2010-04-05 22:27:54 +0000
+++ libmemcached/hosts.c 2011-01-13 03:40:43 +0000
@@ -207,6 +207,7 @@
207 {207 {
208 char sort_host[MEMCACHED_MAX_HOST_SORT_LENGTH]= "";208 char sort_host[MEMCACHED_MAX_HOST_SORT_LENGTH]= "";
209 size_t sort_host_length;209 size_t sort_host_length;
210 uint32_t x;
210211
211 // Spymemcached ketema key format is: hostname/ip:port-index212 // Spymemcached ketema key format is: hostname/ip:port-index
212 // If hostname is not available then: /ip:port-index213 // If hostname is not available then: /ip:port-index
@@ -223,7 +224,7 @@
223224
224 if (is_ketama_weighted)225 if (is_ketama_weighted)
225 {226 {
226 for (uint32_t x= 0; x < pointer_per_hash; x++)227 for (x= 0; x < pointer_per_hash; x++)
227 {228 {
228 value= ketama_server_hash(sort_host, sort_host_length, x);229 value= ketama_server_hash(sort_host, sort_host_length, x);
229 ptr->continuum[continuum_index].index= host_index;230 ptr->continuum[continuum_index].index= host_index;
@@ -246,6 +247,7 @@
246 {247 {
247 char sort_host[MEMCACHED_MAX_HOST_SORT_LENGTH]= "";248 char sort_host[MEMCACHED_MAX_HOST_SORT_LENGTH]= "";
248 size_t sort_host_length;249 size_t sort_host_length;
250 uint32_t x;
249251
250 if (list[host_index].port == MEMCACHED_DEFAULT_PORT)252 if (list[host_index].port == MEMCACHED_DEFAULT_PORT)
251 {253 {
@@ -267,7 +269,7 @@
267269
268 if (is_ketama_weighted)270 if (is_ketama_weighted)
269 {271 {
270 for (uint32_t x = 0; x < pointer_per_hash; x++)272 for (x = 0; x < pointer_per_hash; x++)
271 {273 {
272 value= ketama_server_hash(sort_host, sort_host_length, x);274 value= ketama_server_hash(sort_host, sort_host_length, x);
273 ptr->continuum[continuum_index].index= host_index;275 ptr->continuum[continuum_index].index= host_index;
@@ -305,7 +307,7 @@
305307
306memcached_return_t memcached_server_push(memcached_st *ptr, const memcached_server_list_st list)308memcached_return_t memcached_server_push(memcached_st *ptr, const memcached_server_list_st list)
307{309{
308 uint32_t count;310 uint32_t count, x;
309 memcached_server_st *new_host_list;311 memcached_server_st *new_host_list;
310312
311 if (! list)313 if (! list)
@@ -320,7 +322,7 @@
320322
321 memcached_server_list_set(ptr, new_host_list);323 memcached_server_list_set(ptr, new_host_list);
322324
323 for (uint32_t x= 0; x < count; x++)325 for (x= 0; x < count; x++)
324 {326 {
325 memcached_server_write_instance_st instance;327 memcached_server_write_instance_st instance;
326328
327329
=== modified file 'libmemcached/io.c'
--- libmemcached/io.c 2010-09-15 00:44:32 +0000
+++ libmemcached/io.c 2011-01-13 03:40:43 +0000
@@ -24,12 +24,13 @@
24static memcached_return_t io_wait(memcached_server_write_instance_st ptr,24static memcached_return_t io_wait(memcached_server_write_instance_st ptr,
25 memc_read_or_write read_or_write)25 memc_read_or_write read_or_write)
26{26{
27 struct pollfd fds= {27 struct pollfd fds;
28 .fd= ptr->fd,28 int error, timeout;
29 .events = POLLIN29 size_t loop_max;
30 };
31 int error;
3230
31 fds.fd= ptr->fd;
32 fds.events = POLLIN;
33
33 if (read_or_write == MEM_WRITE) /* write */34 if (read_or_write == MEM_WRITE) /* write */
34 {35 {
35 fds.events= POLLOUT;36 fds.events= POLLOUT;
@@ -55,11 +56,11 @@
55 return MEMCACHED_FAILURE;56 return MEMCACHED_FAILURE;
56 }57 }
5758
58 int timeout= ptr->root->poll_timeout;59 timeout= ptr->root->poll_timeout;
59 if (ptr->root->flags.no_block == false)60 if (ptr->root->flags.no_block == false)
60 timeout= -1;61 timeout= -1;
6162
62 size_t loop_max= 5;63 loop_max= 5;
63 while (--loop_max) // While loop is for ERESTART or EINTR64 while (--loop_max) // While loop is for ERESTART or EINTR
64 {65 {
65 error= poll(&fds, 1, timeout);66 error= poll(&fds, 1, timeout);
@@ -164,6 +165,11 @@
164 */165 */
165 if (ptr->root->callbacks != NULL && ptr->root->flags.use_udp == false)166 if (ptr->root->callbacks != NULL && ptr->root->flags.use_udp == false)
166 {167 {
168 uint32_t x;
169 char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE];
170 memcached_return_t error;
171 memcached_st *root;
172
167 /*173 /*
168 * We might have responses... try to read them out and fire174 * We might have responses... try to read them out and fire
169 * callbacks175 * callbacks
@@ -171,10 +177,8 @@
171 memcached_callback_st cb= *ptr->root->callbacks;177 memcached_callback_st cb= *ptr->root->callbacks;
172178
173 memcached_set_processing_input((memcached_st *)ptr->root, true);179 memcached_set_processing_input((memcached_st *)ptr->root, true);
174180
175 char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE];181 root= (memcached_st *) ptr->root;
176 memcached_return_t error;
177 memcached_st *root= (memcached_st *)ptr->root;
178 error= memcached_response(ptr, buffer, sizeof(buffer),182 error= memcached_response(ptr, buffer, sizeof(buffer),
179 &root->result);183 &root->result);
180184
@@ -182,7 +186,7 @@
182186
183 if (error == MEMCACHED_SUCCESS)187 if (error == MEMCACHED_SUCCESS)
184 {188 {
185 for (unsigned int x= 0; x < cb.number_of_callback; x++)189 for (x= 0; x < cb.number_of_callback; x++)
186 {190 {
187 error= (*cb.callback[x])(ptr->root, &root->result, cb.context);191 error= (*cb.callback[x])(ptr->root, &root->result, cb.context);
188 if (error != MEMCACHED_SUCCESS)192 if (error != MEMCACHED_SUCCESS)
@@ -281,8 +285,10 @@
281 }285 }
282 else if (data_read == SOCKET_ERROR)286 else if (data_read == SOCKET_ERROR)
283 {287 {
284 ptr->cached_errno= get_socket_errno();
285 memcached_return_t rc= MEMCACHED_ERRNO;288 memcached_return_t rc= MEMCACHED_ERRNO;
289
290 ptr->cached_errno= get_socket_errno();
291
286 switch (get_socket_errno())292 switch (get_socket_errno())
287 {293 {
288 case EWOULDBLOCK:294 case EWOULDBLOCK:
@@ -443,9 +449,10 @@
443 const struct libmemcached_io_vector_st *vector,449 const struct libmemcached_io_vector_st *vector,
444 size_t number_of, bool with_flush)450 size_t number_of, bool with_flush)
445{451{
452 size_t x;
446 ssize_t total= 0;453 ssize_t total= 0;
447454
448 for (size_t x= 0; x < number_of; x++, vector++)455 for (x= 0; x < number_of; x++, vector++)
449 {456 {
450 ssize_t returnable;457 ssize_t returnable;
451458
@@ -496,8 +503,10 @@
496#define MAX_SERVERS_TO_POLL 100503#define MAX_SERVERS_TO_POLL 100
497 struct pollfd fds[MAX_SERVERS_TO_POLL];504 struct pollfd fds[MAX_SERVERS_TO_POLL];
498 unsigned int host_index= 0;505 unsigned int host_index= 0;
506 uint32_t x, y;
507 int err;
499508
500 for (uint32_t x= 0;509 for (x= 0;
501 x< memcached_server_count(memc) && host_index < MAX_SERVERS_TO_POLL;510 x< memcached_server_count(memc) && host_index < MAX_SERVERS_TO_POLL;
502 ++x)511 ++x)
503 {512 {
@@ -519,7 +528,7 @@
519 if (host_index < 2)528 if (host_index < 2)
520 {529 {
521 /* We have 0 or 1 server with pending events.. */530 /* We have 0 or 1 server with pending events.. */
522 for (uint32_t x= 0; x< memcached_server_count(memc); ++x)531 for (x= 0; x< memcached_server_count(memc); ++x)
523 {532 {
524 memcached_server_write_instance_st instance=533 memcached_server_write_instance_st instance=
525 memcached_server_instance_fetch(memc, x);534 memcached_server_instance_fetch(memc, x);
@@ -533,7 +542,7 @@
533 return NULL;542 return NULL;
534 }543 }
535544
536 int err= poll(fds, host_index, memc->poll_timeout);545 err= poll(fds, host_index, memc->poll_timeout);
537 switch (err) {546 switch (err) {
538 case -1:547 case -1:
539 memc->cached_errno = get_socket_errno();548 memc->cached_errno = get_socket_errno();
@@ -541,11 +550,11 @@
541 case 0:550 case 0:
542 break;551 break;
543 default:552 default:
544 for (size_t x= 0; x < host_index; ++x)553 for (x= 0; x < host_index; ++x)
545 {554 {
546 if (fds[x].revents & POLLIN)555 if (fds[x].revents & POLLIN)
547 {556 {
548 for (uint32_t y= 0; y < memcached_server_count(memc); ++y)557 for (y= 0; y < memcached_server_count(memc); ++y)
549 {558 {
550 memcached_server_write_instance_st instance=559 memcached_server_write_instance_st instance=
551 memcached_server_instance_fetch(memc, y);560 memcached_server_instance_fetch(memc, y);
@@ -563,6 +572,11 @@
563static ssize_t io_flush(memcached_server_write_instance_st ptr,572static ssize_t io_flush(memcached_server_write_instance_st ptr,
564 memcached_return_t *error)573 memcached_return_t *error)
565{574{
575 ssize_t sent_length;
576 size_t return_length;
577 char *local_write_ptr;
578 size_t write_length;
579
566 /*580 /*
567 ** We might want to purge the input buffer if we haven't consumed581 ** We might want to purge the input buffer if we haven't consumed
568 ** any output yet... The test for the limits is the purge is inline582 ** any output yet... The test for the limits is the purge is inline
@@ -576,10 +590,9 @@
576 if (rc != MEMCACHED_SUCCESS && rc != MEMCACHED_STORED)590 if (rc != MEMCACHED_SUCCESS && rc != MEMCACHED_STORED)
577 return -1;591 return -1;
578 }592 }
579 ssize_t sent_length;593
580 size_t return_length;594 local_write_ptr= ptr->write_buffer;
581 char *local_write_ptr= ptr->write_buffer;595 write_length= ptr->write_buffer_offset;
582 size_t write_length= ptr->write_buffer_offset;
583596
584 *error= MEMCACHED_SUCCESS;597 *error= MEMCACHED_SUCCESS;
585598
@@ -626,6 +639,8 @@
626 case EAGAIN:639 case EAGAIN:
627#endif640#endif
628 {641 {
642 memcached_return_t rc;
643
629 /*644 /*
630 * We may be blocked on write because the input buffer645 * We may be blocked on write because the input buffer
631 * is full. Let's check if we have room in our input646 * is full. Let's check if we have room in our input
@@ -635,8 +650,7 @@
635 if (repack_input_buffer(ptr) ||650 if (repack_input_buffer(ptr) ||
636 process_input_buffer(ptr))651 process_input_buffer(ptr))
637 continue;652 continue;
638653
639 memcached_return_t rc;
640 rc= io_wait(ptr, MEM_WRITE);654 rc= io_wait(ptr, MEM_WRITE);
641655
642 if (rc == MEMCACHED_SUCCESS || rc == MEMCACHED_TIMEOUT)656 if (rc == MEMCACHED_SUCCESS || rc == MEMCACHED_TIMEOUT)
@@ -786,10 +800,12 @@
786800
787memcached_return_t memcached_io_init_udp_header(memcached_server_write_instance_st ptr, uint16_t thread_id)801memcached_return_t memcached_io_init_udp_header(memcached_server_write_instance_st ptr, uint16_t thread_id)
788{802{
803 struct udp_datagram_header_st *header;
804
789 if (thread_id > UDP_REQUEST_ID_MAX_THREAD_ID)805 if (thread_id > UDP_REQUEST_ID_MAX_THREAD_ID)
790 return MEMCACHED_FAILURE;806 return MEMCACHED_FAILURE;
791807
792 struct udp_datagram_header_st *header= (struct udp_datagram_header_st *)ptr->write_buffer;808 header= (struct udp_datagram_header_st *)ptr->write_buffer;
793 header->request_id= htons((uint16_t) (generate_udp_request_thread_id(thread_id)));809 header->request_id= htons((uint16_t) (generate_udp_request_thread_id(thread_id)));
794 header->num_datagrams= htons(1);810 header->num_datagrams= htons(1);
795 header->sequence_number= htons(0);811 header->sequence_number= htons(0);
796812
=== modified file 'libmemcached/memcached.c'
--- libmemcached/memcached.c 2010-09-13 06:05:34 +0000
+++ libmemcached/memcached.c 2011-01-13 03:40:43 +0000
@@ -11,41 +11,29 @@
1111
12#include "common.h"12#include "common.h"
1313
14static const memcached_st global_copy= {14const memcached_st *create_global_copy()
15 .state= {15{
16 .is_purging= false,16 memcached_st *global = (memcached_st *) malloc(sizeof(memcached_st));
17 .is_processing_input= false,17
18 .is_time_for_rebuild= false,18 memset(global, 0, sizeof(memcached_st));
19 },19
20 .flags= {20 return global;
21 .auto_eject_hosts= false,21}
22 .binary_protocol= false,22
23 .buffer_requests= false,23static const memcached_st *global_copy = NULL;
24 .cork= false,
25 .hash_with_prefix_key= false,
26 .ketama_weighted= false,
27 .no_block= false,
28 .no_reply= false,
29 .randomize_replica_read= false,
30 .reuse_memory= false,
31 .support_cas= false,
32 .tcp_nodelay= false,
33 .use_cache_lookups= false,
34 .use_sort_hosts= false,
35 .use_udp= false,
36 .verify_key= false,
37 .tcp_keepalive= false
38 }
39};
4024
41static inline bool _memcached_init(memcached_st *self)25static inline bool _memcached_init(memcached_st *self)
42{26{
43 self->state= global_copy.state;27 hashkit_st *hash_ptr;
44 self->flags= global_copy.flags;28
29 if (global_copy == NULL)
30 global_copy = create_global_copy();
31
32 self->state= global_copy->state;
33 self->flags= global_copy->flags;
4534
46 self->distribution= MEMCACHED_DISTRIBUTION_MODULA;35 self->distribution= MEMCACHED_DISTRIBUTION_MODULA;
4736
48 hashkit_st *hash_ptr;
49 hash_ptr= hashkit_create(&self->hashkit);37 hash_ptr= hashkit_create(&self->hashkit);
50 if (! hash_ptr)38 if (! hash_ptr)
51 return false;39 return false;
@@ -199,6 +187,7 @@
199{187{
200 memcached_return_t rc= MEMCACHED_SUCCESS;188 memcached_return_t rc= MEMCACHED_SUCCESS;
201 memcached_st *new_clone;189 memcached_st *new_clone;
190 hashkit_st *hash_ptr;
202191
203 if (source == NULL)192 if (source == NULL)
204 return memcached_create(clone);193 return memcached_create(clone);
@@ -221,8 +210,6 @@
221 new_clone->retry_timeout= source->retry_timeout;210 new_clone->retry_timeout= source->retry_timeout;
222 new_clone->distribution= source->distribution;211 new_clone->distribution= source->distribution;
223212
224 hashkit_st *hash_ptr;
225
226 hash_ptr= hashkit_clone(&new_clone->hashkit, &source->hashkit);213 hash_ptr= hashkit_clone(&new_clone->hashkit, &source->hashkit);
227 if (! hash_ptr)214 if (! hash_ptr)
228 {215 {
229216
=== modified file 'libmemcached/memcached.h'
--- libmemcached/memcached.h 2010-09-13 06:05:34 +0000
+++ libmemcached/memcached.h 2011-01-13 03:40:43 +0000
@@ -111,13 +111,7 @@
111 memcached_result_st result;111 memcached_result_st result;
112 memcached_continuum_item_st *continuum; // Ketama112 memcached_continuum_item_st *continuum; // Ketama
113113
114 struct _allocators_st {114 allocators_st *allocators;
115 memcached_calloc_fn calloc;
116 memcached_free_fn free;
117 memcached_malloc_fn malloc;
118 memcached_realloc_fn realloc;
119 void *context;
120 } allocators;
121115
122 memcached_clone_fn on_clone;116 memcached_clone_fn on_clone;
123 memcached_cleanup_fn on_cleanup;117 memcached_cleanup_fn on_cleanup;
124118
=== modified file 'libmemcached/purge.c'
--- libmemcached/purge.c 2010-02-13 02:23:49 +0000
+++ libmemcached/purge.c 2011-01-13 03:40:43 +0000
@@ -2,7 +2,7 @@
22
3memcached_return_t memcached_purge(memcached_server_write_instance_st ptr)3memcached_return_t memcached_purge(memcached_server_write_instance_st ptr)
4{4{
5 uint32_t x;5 uint32_t x, no_msg;
6 memcached_return_t ret= MEMCACHED_SUCCESS;6 memcached_return_t ret= MEMCACHED_SUCCESS;
7 memcached_st *root= (memcached_st *)ptr->root;7 memcached_st *root= (memcached_st *)ptr->root;
88
@@ -30,7 +30,7 @@
30 }30 }
31 WATCHPOINT_ASSERT(ptr->fd != -1);31 WATCHPOINT_ASSERT(ptr->fd != -1);
3232
33 uint32_t no_msg= memcached_server_response_count(ptr) - 1;33 no_msg= memcached_server_response_count(ptr) - 1;
34 if (no_msg > 0)34 if (no_msg > 0)
35 {35 {
36 memcached_result_st result;36 memcached_result_st result;
@@ -50,10 +50,10 @@
5050
51 for (x= 0; x < no_msg; x++)51 for (x= 0; x < no_msg; x++)
52 {52 {
53 memcached_return_t rc;
54
53 memcached_result_reset(result_ptr);55 memcached_result_reset(result_ptr);
54 memcached_return_t rc= memcached_read_one_response(ptr, buffer,56 rc= memcached_read_one_response(ptr, buffer, sizeof (buffer), result_ptr);
55 sizeof (buffer),
56 result_ptr);
57 /*57 /*
58 * Purge doesn't care for what kind of command results that is received.58 * Purge doesn't care for what kind of command results that is received.
59 * The only kind of errors I care about if is I'm out of sync with the59 * The only kind of errors I care about if is I'm out of sync with the
@@ -69,9 +69,11 @@
69 if (ptr->root->callbacks != NULL)69 if (ptr->root->callbacks != NULL)
70 {70 {
71 memcached_callback_st cb = *ptr->root->callbacks;71 memcached_callback_st cb = *ptr->root->callbacks;
72 uint32_t y;
73
72 if (rc == MEMCACHED_SUCCESS)74 if (rc == MEMCACHED_SUCCESS)
73 {75 {
74 for (uint32_t y= 0; y < cb.number_of_callback; y++)76 for (y= 0; y < cb.number_of_callback; y++)
75 {77 {
76 rc = (*cb.callback[y])(ptr->root, result_ptr, cb.context);78 rc = (*cb.callback[y])(ptr->root, result_ptr, cb.context);
77 if (rc != MEMCACHED_SUCCESS)79 if (rc != MEMCACHED_SUCCESS)
7880
=== modified file 'libmemcached/quit.c'
--- libmemcached/quit.c 2010-04-22 00:49:09 +0000
+++ libmemcached/quit.c 2011-01-13 03:40:43 +0000
@@ -22,7 +22,10 @@
2222
23 if (ptr->root->flags.binary_protocol)23 if (ptr->root->flags.binary_protocol)
24 {24 {
25 protocol_binary_request_quit request = {.bytes= {0}};25 protocol_binary_request_quit request;
26
27 memset(&request, 0, sizeof(request));
28
26 request.message.header.request.magic = PROTOCOL_BINARY_REQ;29 request.message.header.request.magic = PROTOCOL_BINARY_REQ;
27 request.message.header.request.opcode = PROTOCOL_BINARY_CMD_QUIT;30 request.message.header.request.opcode = PROTOCOL_BINARY_CMD_QUIT;
28 request.message.header.request.datatype = PROTOCOL_BINARY_RAW_BYTES;31 request.message.header.request.datatype = PROTOCOL_BINARY_RAW_BYTES;
2932
=== modified file 'libmemcached/response.c'
--- libmemcached/response.c 2010-07-16 03:54:57 +0000
+++ libmemcached/response.c 2011-01-13 03:40:43 +0000
@@ -22,6 +22,8 @@
22 char *buffer, size_t buffer_length,22 char *buffer, size_t buffer_length,
23 memcached_result_st *result)23 memcached_result_st *result)
24{24{
25 memcached_return_t rc;
26
25 memcached_server_response_decrement(ptr);27 memcached_server_response_decrement(ptr);
2628
27 if (result == NULL)29 if (result == NULL)
@@ -29,8 +31,7 @@
29 memcached_st *root= (memcached_st *)ptr->root;31 memcached_st *root= (memcached_st *)ptr->root;
30 result = &root->result;32 result = &root->result;
31 }33 }
3234
33 memcached_return_t rc;
34 if (ptr->root->flags.binary_protocol)35 if (ptr->root->flags.binary_protocol)
35 rc= binary_read_one_response(ptr, buffer, buffer_length, result);36 rc= binary_read_one_response(ptr, buffer, buffer_length, result);
36 else37 else
@@ -341,6 +342,7 @@
341{342{
342 memcached_return_t rc;343 memcached_return_t rc;
343 protocol_binary_response_header header;344 protocol_binary_response_header header;
345 uint32_t bodylen;
344346
345 if ((rc= memcached_safe_read(ptr, &header.bytes, sizeof(header.bytes))) != MEMCACHED_SUCCESS)347 if ((rc= memcached_safe_read(ptr, &header.bytes, sizeof(header.bytes))) != MEMCACHED_SUCCESS)
346 {348 {
@@ -360,7 +362,7 @@
360 header.response.status= ntohs(header.response.status);362 header.response.status= ntohs(header.response.status);
361 header.response.bodylen= ntohl(header.response.bodylen);363 header.response.bodylen= ntohl(header.response.bodylen);
362 header.response.cas= ntohll(header.response.cas);364 header.response.cas= ntohll(header.response.cas);
363 uint32_t bodylen= header.response.bodylen;365 bodylen= header.response.bodylen;
364366
365 if (header.response.status == PROTOCOL_BINARY_RESPONSE_SUCCESS ||367 if (header.response.status == PROTOCOL_BINARY_RESPONSE_SUCCESS ||
366 header.response.status == PROTOCOL_BINARY_RESPONSE_AUTH_CONTINUE)368 header.response.status == PROTOCOL_BINARY_RESPONSE_AUTH_CONTINUE)
@@ -376,6 +378,7 @@
376 /* FALLTHROUGH */378 /* FALLTHROUGH */
377 case PROTOCOL_BINARY_CMD_GETK:379 case PROTOCOL_BINARY_CMD_GETK:
378 {380 {
381 char *vptr;
379 uint16_t keylen= header.response.keylen;382 uint16_t keylen= header.response.keylen;
380 memcached_result_reset(result);383 memcached_result_reset(result);
381 result->item_cas= header.response.cas;384 result->item_cas= header.response.cas;
@@ -401,7 +404,7 @@
401 bodylen) != MEMCACHED_SUCCESS)404 bodylen) != MEMCACHED_SUCCESS)
402 return MEMCACHED_MEMORY_ALLOCATION_FAILURE;405 return MEMCACHED_MEMORY_ALLOCATION_FAILURE;
403406
404 char *vptr= memcached_string_value_mutable(&result->value);407 vptr= memcached_string_value_mutable(&result->value);
405 if ((rc= memcached_safe_read(ptr, vptr, bodylen)) != MEMCACHED_SUCCESS)408 if ((rc= memcached_safe_read(ptr, vptr, bodylen)) != MEMCACHED_SUCCESS)
406 {409 {
407 WATCHPOINT_ERROR(rc);410 WATCHPOINT_ERROR(rc);
@@ -414,11 +417,13 @@
414 case PROTOCOL_BINARY_CMD_INCREMENT:417 case PROTOCOL_BINARY_CMD_INCREMENT:
415 case PROTOCOL_BINARY_CMD_DECREMENT:418 case PROTOCOL_BINARY_CMD_DECREMENT:
416 {419 {
420 uint64_t val;
421
417 if (bodylen != sizeof(uint64_t) || buffer_length != sizeof(uint64_t))422 if (bodylen != sizeof(uint64_t) || buffer_length != sizeof(uint64_t))
418 return MEMCACHED_PROTOCOL_ERROR;423 return MEMCACHED_PROTOCOL_ERROR;
419424
420 WATCHPOINT_ASSERT(bodylen == buffer_length);425 WATCHPOINT_ASSERT(bodylen == buffer_length);
421 uint64_t val;426
422 if ((rc= memcached_safe_read(ptr, &val, sizeof(val))) != MEMCACHED_SUCCESS)427 if ((rc= memcached_safe_read(ptr, &val, sizeof(val))) != MEMCACHED_SUCCESS)
423 {428 {
424 WATCHPOINT_ERROR(rc);429 WATCHPOINT_ERROR(rc);
@@ -490,6 +495,8 @@
490 case PROTOCOL_BINARY_CMD_SASL_AUTH:495 case PROTOCOL_BINARY_CMD_SASL_AUTH:
491 case PROTOCOL_BINARY_CMD_SASL_STEP:496 case PROTOCOL_BINARY_CMD_SASL_STEP:
492 {497 {
498 char * vptr;
499
493 memcached_result_reset(result);500 memcached_result_reset(result);
494 result->item_cas= header.response.cas;501 result->item_cas= header.response.cas;
495502
@@ -497,7 +504,7 @@
497 bodylen) != MEMCACHED_SUCCESS)504 bodylen) != MEMCACHED_SUCCESS)
498 return MEMCACHED_MEMORY_ALLOCATION_FAILURE;505 return MEMCACHED_MEMORY_ALLOCATION_FAILURE;
499506
500 char *vptr= memcached_string_value_mutable(&result->value);507 vptr= memcached_string_value_mutable(&result->value);
501 if ((rc= memcached_safe_read(ptr, vptr, bodylen)) != MEMCACHED_SUCCESS)508 if ((rc= memcached_safe_read(ptr, vptr, bodylen)) != MEMCACHED_SUCCESS)
502 {509 {
503 WATCHPOINT_ERROR(rc);510 WATCHPOINT_ERROR(rc);
504511
=== modified file 'libmemcached/sasl.c'
--- libmemcached/sasl.c 2010-09-13 12:26:17 +0000
+++ libmemcached/sasl.c 2011-01-13 03:40:43 +0000
@@ -11,6 +11,8 @@
11 */11 */
12#include "common.h"12#include "common.h"
1313
14#ifdef LIBMEMCACHED_WITH_SASL_SUPPORT
15
14void memcached_set_sasl_callbacks(memcached_st *ptr,16void memcached_set_sasl_callbacks(memcached_st *ptr,
15 const sasl_callback_t *callbacks)17 const sasl_callback_t *callbacks)
16{18{
@@ -373,3 +375,5 @@
373375
374 return MEMCACHED_SUCCESS;376 return MEMCACHED_SUCCESS;
375}377}
378
379#endif
376380
=== modified file 'libmemcached/server.c'
--- libmemcached/server.c 2010-07-16 02:33:19 +0000
+++ libmemcached/server.c 2011-01-13 03:40:43 +0000
@@ -153,12 +153,14 @@
153 void *context,153 void *context,
154 uint32_t number_of_callbacks)154 uint32_t number_of_callbacks)
155{155{
156 for (uint32_t x= 0; x < memcached_server_count(ptr); x++)156 uint32_t x, y;
157
158 for (x= 0; x < memcached_server_count(ptr); x++)
157 {159 {
158 memcached_server_instance_st instance=160 memcached_server_instance_st instance=
159 memcached_server_instance_by_position(ptr, x);161 memcached_server_instance_by_position(ptr, x);
160162
161 for (uint32_t y= 0; y < number_of_callbacks; y++)163 for (y= 0; y < number_of_callbacks; y++)
162 {164 {
163 unsigned int iferror;165 unsigned int iferror;
164166
@@ -176,7 +178,9 @@
176 memcached_server_execute_fn callback,178 memcached_server_execute_fn callback,
177 void *context)179 void *context)
178{180{
179 for (uint32_t x= 0; x < memcached_server_count(ptr); x++)181 uint32_t x;
182
183 for (x= 0; x < memcached_server_count(ptr); x++)
180 {184 {
181 memcached_server_write_instance_st instance=185 memcached_server_write_instance_st instance=
182 memcached_server_instance_fetch(ptr, x);186 memcached_server_instance_fetch(ptr, x);
@@ -236,12 +240,15 @@
236240
237void memcached_server_list_free(memcached_server_list_st self)241void memcached_server_list_free(memcached_server_list_st self)
238{242{
243 const memcached_st *root;
244 uint32_t x;
245
239 if (self == NULL)246 if (self == NULL)
240 return;247 return;
241248
242 const memcached_st *root= self->root;249 root= self->root;
243250
244 for (uint32_t x= 0; x < memcached_server_list_count(self); x++)251 for (x= 0; x < memcached_server_list_count(self); x++)
245 {252 {
246 if (self[x].address_info)253 if (self[x].address_info)
247 {254 {
248255
=== modified file 'libmemcached/stats.c'
--- libmemcached/stats.c 2010-09-13 12:26:17 +0000
+++ libmemcached/stats.c 2011-01-13 03:40:43 +0000
@@ -242,13 +242,18 @@
242 memcached_return_t rc;242 memcached_return_t rc;
243243
244 char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE];244 char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE];
245 protocol_binary_request_stats request= {.bytes= {0}};245 protocol_binary_request_stats request;
246
247 memset(&request, 0, sizeof(request));
248
246 request.message.header.request.magic= PROTOCOL_BINARY_REQ;249 request.message.header.request.magic= PROTOCOL_BINARY_REQ;
247 request.message.header.request.opcode= PROTOCOL_BINARY_CMD_STAT;250 request.message.header.request.opcode= PROTOCOL_BINARY_CMD_STAT;
248 request.message.header.request.datatype= PROTOCOL_BINARY_RAW_BYTES;251 request.message.header.request.datatype= PROTOCOL_BINARY_RAW_BYTES;
249252
250 if (args != NULL)253 if (args != NULL)
251 {254 {
255 struct libmemcached_io_vector_st vector[2];
256
252 size_t len= strlen(args);257 size_t len= strlen(args);
253258
254 rc= memcached_validate_key_length(len, true);259 rc= memcached_validate_key_length(len, true);
@@ -258,11 +263,10 @@
258 request.message.header.request.keylen= htons((uint16_t)len);263 request.message.header.request.keylen= htons((uint16_t)len);
259 request.message.header.request.bodylen= htonl((uint32_t) len);264 request.message.header.request.bodylen= htonl((uint32_t) len);
260265
261 struct libmemcached_io_vector_st vector[]=266 vector[0].length= sizeof(request.bytes);
262 {267 vector[0].buffer= request.bytes;
263 { .length= sizeof(request.bytes), .buffer= request.bytes },268 vector[1].length= len;
264 { .length= len, .buffer= args }269 vector[1].buffer= args;
265 };
266270
267 if (memcached_vdo(instance, vector, 2, true) != MEMCACHED_SUCCESS)271 if (memcached_vdo(instance, vector, 2, true) != MEMCACHED_SUCCESS)
268 {272 {
@@ -397,6 +401,7 @@
397{401{
398 memcached_return_t rc;402 memcached_return_t rc;
399 memcached_stat_st *stats;403 memcached_stat_st *stats;
404 uint32_t x;
400405
401 unlikely (ptr->flags.use_udp)406 unlikely (ptr->flags.use_udp)
402 {407 {
@@ -413,7 +418,7 @@
413 }418 }
414419
415 rc= MEMCACHED_SUCCESS;420 rc= MEMCACHED_SUCCESS;
416 for (uint32_t x= 0; x < memcached_server_count(ptr); x++)421 for (x= 0; x < memcached_server_count(ptr); x++)
417 {422 {
418 memcached_return_t temp_return;423 memcached_return_t temp_return;
419 memcached_server_write_instance_st instance;424 memcached_server_write_instance_st instance;
@@ -544,9 +549,13 @@
544549
545memcached_return_t memcached_stat_execute(memcached_st *memc, const char *args, memcached_stat_fn func, void *context)550memcached_return_t memcached_stat_execute(memcached_st *memc, const char *args, memcached_stat_fn func, void *context)
546{551{
552 struct local_context check;
553
547 memcached_version(memc);554 memcached_version(memc);
548555
549 struct local_context check= { .func= func, .context= context, .args= args };556 check.func= func;
557 check.context= context;
558 check.args= args;
550559
551 return memcached_server_execute(memc, call_stat_fn, (void *)&check);560 return memcached_server_execute(memc, call_stat_fn, (void *)&check);
552}561}
553562
=== modified file 'libmemcached/storage.c'
--- libmemcached/storage.c 2010-09-13 12:26:17 +0000
+++ libmemcached/storage.c 2011-01-13 03:40:43 +0000
@@ -105,12 +105,13 @@
105 if (cas)105 if (cas)
106 {106 {
107 write_length= (size_t) snprintf(buffer, MEMCACHED_DEFAULT_COMMAND_SIZE,107 write_length= (size_t) snprintf(buffer, MEMCACHED_DEFAULT_COMMAND_SIZE,
108 "%s %.*s%.*s %u %llu %zu %llu%s\r\n",108 "%s %.*s%.*s %u %llu %lu %llu%s\r\n",
109 storage_op_string(verb),109 storage_op_string(verb),
110 (int)ptr->prefix_key_length,110 (int)ptr->prefix_key_length,
111 ptr->prefix_key,111 ptr->prefix_key,
112 (int)key_length, key, flags,112 (int)key_length, key, flags,
113 (unsigned long long)expiration, value_length,113 (unsigned long long)expiration,
114 (unsigned long)value_length,
114 (unsigned long long)cas,115 (unsigned long long)cas,
115 (ptr->flags.no_reply) ? " noreply" : "");116 (ptr->flags.no_reply) ? " noreply" : "");
116 }117 }
@@ -134,9 +135,10 @@
134135
135 write_length= (size_t)(buffer_ptr - buffer);136 write_length= (size_t)(buffer_ptr - buffer);
136 write_length+= (size_t) snprintf(buffer_ptr, MEMCACHED_DEFAULT_COMMAND_SIZE,137 write_length+= (size_t) snprintf(buffer_ptr, MEMCACHED_DEFAULT_COMMAND_SIZE,
137 "%u %llu %zu%s\r\n",138 "%u %llu %lu%s\r\n",
138 flags,139 flags,
139 (unsigned long long)expiration, value_length,140 (unsigned long long)expiration,
141 (unsigned long)value_length,
140 ptr->flags.no_reply ? " noreply" : "");142 ptr->flags.no_reply ? " noreply" : "");
141 }143 }
142144
@@ -155,12 +157,14 @@
155 }157 }
156 else158 else
157 {159 {
158 struct libmemcached_io_vector_st vector[]=160 struct libmemcached_io_vector_st vector[3];
159 {161
160 { .length= write_length, .buffer= buffer },162 vector[0].length= write_length;
161 { .length= value_length, .buffer= value },163 vector[0].buffer= buffer;
162 { .length= 2, .buffer= "\r\n" }164 vector[1].length= value_length;
163 };165 vector[1].buffer= value;
166 vector[2].length= 2;
167 vector[2].buffer= "\r\n";
164168
165 if (ptr->flags.buffer_requests && verb == SET_OP)169 if (ptr->flags.buffer_requests && verb == SET_OP)
166 {170 {
@@ -452,11 +456,15 @@
452 memcached_storage_action_t verb)456 memcached_storage_action_t verb)
453{457{
454 bool flush;458 bool flush;
455 protocol_binary_request_set request= {.bytes= {0}};459 protocol_binary_request_set request;
456 size_t send_length= sizeof(request.bytes);460 size_t send_length= sizeof(request.bytes);
457461 memcached_return_t rc;
462 struct libmemcached_io_vector_st vector[4];
463
458 bool noreply= server->root->flags.no_reply;464 bool noreply= server->root->flags.no_reply;
459465
466 memset(&request, 0, sizeof(request));
467
460 request.message.header.request.magic= PROTOCOL_BINARY_REQ;468 request.message.header.request.magic= PROTOCOL_BINARY_REQ;
461 request.message.header.request.opcode= get_com_code(verb, noreply);469 request.message.header.request.opcode= get_com_code(verb, noreply);
462 request.message.header.request.keylen= htons((uint16_t)(key_length + ptr->prefix_key_length));470 request.message.header.request.keylen= htons((uint16_t)(key_length + ptr->prefix_key_length));
@@ -492,16 +500,17 @@
492 }500 }
493 }501 }
494502
495 struct libmemcached_io_vector_st vector[]=503
496 {504 vector[0].length= send_length;
497 { .length= send_length, .buffer= request.bytes },505 vector[0].buffer= request.bytes;
498 { .length= ptr->prefix_key_length, .buffer= ptr->prefix_key },506 vector[1].length= ptr->prefix_key_length;
499 { .length= key_length, .buffer= key },507 vector[1].buffer= ptr->prefix_key;
500 { .length= value_length, .buffer= value }508 vector[2].length= key_length;
501 };509 vector[2].buffer= key;
510 vector[3].length= value_length;
511 vector[3].buffer= value;
502512
503 /* write the header */513 /* write the header */
504 memcached_return_t rc;
505 if ((rc= memcached_vdo(server, vector, 4, flush)) != MEMCACHED_SUCCESS)514 if ((rc= memcached_vdo(server, vector, 4, flush)) != MEMCACHED_SUCCESS)
506 {515 {
507 memcached_io_reset(server);516 memcached_io_reset(server);
@@ -510,10 +519,12 @@
510519
511 if (verb == SET_OP && ptr->number_of_replicas > 0)520 if (verb == SET_OP && ptr->number_of_replicas > 0)
512 {521 {
522 uint32_t x;
523
513 request.message.header.request.opcode= PROTOCOL_BINARY_CMD_SETQ;524 request.message.header.request.opcode= PROTOCOL_BINARY_CMD_SETQ;
514 WATCHPOINT_STRING("replicating");525 WATCHPOINT_STRING("replicating");
515526
516 for (uint32_t x= 0; x < ptr->number_of_replicas; x++)527 for (x= 0; x < ptr->number_of_replicas; x++)
517 {528 {
518 memcached_server_write_instance_st instance;529 memcached_server_write_instance_st instance;
519530
520531
=== modified file 'libmemcached/types.h'
--- libmemcached/types.h 2010-07-16 02:33:19 +0000
+++ libmemcached/types.h 2011-01-13 03:40:43 +0000
@@ -44,6 +44,13 @@
44typedef void *(*memcached_realloc_fn)(const memcached_st *ptr, void *mem, const size_t size, void *context);44typedef void *(*memcached_realloc_fn)(const memcached_st *ptr, void *mem, const size_t size, void *context);
45typedef void *(*memcached_calloc_fn)(const memcached_st *ptr, size_t nelem, const size_t elsize, void *context);45typedef void *(*memcached_calloc_fn)(const memcached_st *ptr, size_t nelem, const size_t elsize, void *context);
4646
47typedef struct _allocators_st {
48 memcached_calloc_fn calloc;
49 memcached_free_fn free;
50 memcached_malloc_fn malloc;
51 memcached_realloc_fn realloc;
52 void *context;
53} allocators_st;
4754
48typedef memcached_return_t (*memcached_execute_fn)(const memcached_st *ptr, memcached_result_st *result, void *context);55typedef memcached_return_t (*memcached_execute_fn)(const memcached_st *ptr, memcached_result_st *result, void *context);
49typedef memcached_return_t (*memcached_server_fn)(const memcached_st *ptr, memcached_server_instance_st server, void *context);56typedef memcached_return_t (*memcached_server_fn)(const memcached_st *ptr, memcached_server_instance_st server, void *context);
5057
=== modified file 'libmemcached/verbosity.c'
--- libmemcached/verbosity.c 2010-04-04 21:53:03 +0000
+++ libmemcached/verbosity.c 2011-01-13 03:40:43 +0000
@@ -43,6 +43,7 @@
43{43{
44 size_t send_length;44 size_t send_length;
45 memcached_server_fn callbacks[1];45 memcached_server_fn callbacks[1];
46 struct context_st context;
4647
47 char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE];48 char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE];
4849
@@ -51,7 +52,8 @@
51 unlikely (send_length >= MEMCACHED_DEFAULT_COMMAND_SIZE)52 unlikely (send_length >= MEMCACHED_DEFAULT_COMMAND_SIZE)
52 return MEMCACHED_WRITE_FAILURE;53 return MEMCACHED_WRITE_FAILURE;
5354
54 struct context_st context = { .length= send_length, .buffer= buffer };55 context.length= send_length;
56 context.buffer= buffer;
5557
56 callbacks[0]= _set_verbosity;58 callbacks[0]= _set_verbosity;
5759
5860
=== modified file 'libmemcached/version.c'
--- libmemcached/version.c 2010-07-16 03:54:57 +0000
+++ libmemcached/version.c 2011-01-13 03:40:43 +0000
@@ -10,11 +10,13 @@
1010
11memcached_return_t memcached_version(memcached_st *ptr)11memcached_return_t memcached_version(memcached_st *ptr)
12{12{
13 bool was_blocking;
14 memcached_return_t rc;
15
13 if (ptr->flags.use_udp)16 if (ptr->flags.use_udp)
14 return MEMCACHED_NOT_SUPPORTED;17 return MEMCACHED_NOT_SUPPORTED;
1518
16 bool was_blocking= ptr->flags.no_block;19 was_blocking= ptr->flags.no_block;
17 memcached_return_t rc;
1820
19 ptr->flags.no_block= false;21 ptr->flags.no_block= false;
2022
@@ -35,11 +37,12 @@
35 char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE];37 char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE];
36 char *response_ptr;38 char *response_ptr;
37 const char *command= "version\r\n";39 const char *command= "version\r\n";
40 uint32_t x;
3841
39 send_length= strlen(command);42 send_length= strlen(command);
4043
41 rc= MEMCACHED_SUCCESS;44 rc= MEMCACHED_SUCCESS;
42 for (uint32_t x= 0; x < memcached_server_count(ptr); x++)45 for (x= 0; x < memcached_server_count(ptr); x++)
43 {46 {
44 memcached_return_t rrc;47 memcached_return_t rrc;
45 memcached_server_write_instance_st instance=48 memcached_server_write_instance_st instance=
@@ -78,13 +81,17 @@
78static inline memcached_return_t memcached_version_binary(memcached_st *ptr)81static inline memcached_return_t memcached_version_binary(memcached_st *ptr)
79{82{
80 memcached_return_t rc;83 memcached_return_t rc;
81 protocol_binary_request_version request= { .bytes= {0}};84 uint32_t x;
85 protocol_binary_request_version request;
86
87 memset(&request, 0, sizeof(request));
88
82 request.message.header.request.magic= PROTOCOL_BINARY_REQ;89 request.message.header.request.magic= PROTOCOL_BINARY_REQ;
83 request.message.header.request.opcode= PROTOCOL_BINARY_CMD_VERSION;90 request.message.header.request.opcode= PROTOCOL_BINARY_CMD_VERSION;
84 request.message.header.request.datatype= PROTOCOL_BINARY_RAW_BYTES;91 request.message.header.request.datatype= PROTOCOL_BINARY_RAW_BYTES;
8592
86 rc= MEMCACHED_SUCCESS;93 rc= MEMCACHED_SUCCESS;
87 for (uint32_t x= 0; x < memcached_server_count(ptr); x++) 94 for (x= 0; x < memcached_server_count(ptr); x++)
88 {95 {
89 memcached_return_t rrc;96 memcached_return_t rrc;
9097
@@ -100,7 +107,7 @@
100 }107 }
101 }108 }
102109
103 for (uint32_t x= 0; x < memcached_server_count(ptr); x++) 110 for (x= 0; x < memcached_server_count(ptr); x++)
104 {111 {
105 memcached_server_write_instance_st instance=112 memcached_server_write_instance_st instance=
106 memcached_server_instance_fetch(ptr, x);113 memcached_server_instance_fetch(ptr, x);
107114
=== modified file 'libmemcached/visibility.h'
--- libmemcached/visibility.h 2010-01-21 23:45:12 +0000
+++ libmemcached/visibility.h 2011-01-13 03:40:43 +0000
@@ -35,16 +35,26 @@
35# define LIBMEMCACHED_API __global35# define LIBMEMCACHED_API __global
36# define LIBMEMCACHED_LOCAL __hidden36# define LIBMEMCACHED_LOCAL __hidden
37# elif defined(_MSC_VER)37# elif defined(_MSC_VER)
38# define LIBMEMCACHED_API extern __declspec(dllexport) 38# if defined(LIBMEMCACHED_STATIC)
39# define LIBMEMCACHED_LOCAL39# define LIBMEMCACHED_API
40# define LIBMEMCACHED_LOCAL
41# else
42# define LIBMEMCACHED_API extern __declspec(dllexport)
43# define LIBMEMCACHED_LOCAL
44# endif
40# else45# else
41# define LIBMEMCACHED_API46# define LIBMEMCACHED_API
42# define LIBMEMCACHED_LOCAL47# define LIBMEMCACHED_LOCAL
43# endif /* defined(HAVE_VISIBILITY) */48# endif /* defined(HAVE_VISIBILITY) */
44#else /* defined(BUILDING_LIBMEMCACHED) */49#else /* defined(BUILDING_LIBMEMCACHED) */
45# if defined(_MSC_VER)50# if defined(_MSC_VER)
46# define LIBMEMCACHED_API extern __declspec(dllimport) 51# if defined(LIBMEMCACHED_STATIC)
47# define LIBMEMCACHED_LOCAL52# define LIBMEMCACHED_API
53# define LIBMEMCACHED_LOCAL
54# else
55# define LIBMEMCACHED_API extern __declspec(dllimport)
56# define LIBMEMCACHED_LOCAL
57# endif
48# else58# else
49# define LIBMEMCACHED_API59# define LIBMEMCACHED_API
50# define LIBMEMCACHED_LOCAL60# define LIBMEMCACHED_LOCAL
5161
=== modified file 'libmemcached/watchpoint.h'
--- libmemcached/watchpoint.h 2010-09-13 12:31:19 +0000
+++ libmemcached/watchpoint.h 2011-01-13 03:40:43 +0000
@@ -58,9 +58,9 @@
58#define WATCHPOINT_IFERROR(A) do { if(A != MEMCACHED_SUCCESS)fprintf(stderr, "\nWATCHPOINT %s:%d %s\n", __FILE__, __LINE__, memcached_strerror(NULL, A));fflush(stdout); } while (0)58#define WATCHPOINT_IFERROR(A) do { if(A != MEMCACHED_SUCCESS)fprintf(stderr, "\nWATCHPOINT %s:%d %s\n", __FILE__, __LINE__, memcached_strerror(NULL, A));fflush(stdout); } while (0)
59#define WATCHPOINT_STRING(A) do { fprintf(stderr, "\nWATCHPOINT %s:%d (%s) %s\n", __FILE__, __LINE__,__func__,A);fflush(stdout); } while (0)59#define WATCHPOINT_STRING(A) do { fprintf(stderr, "\nWATCHPOINT %s:%d (%s) %s\n", __FILE__, __LINE__,__func__,A);fflush(stdout); } while (0)
60#define WATCHPOINT_STRING_LENGTH(A,B) do { fprintf(stderr, "\nWATCHPOINT %s:%d (%s) %.*s\n", __FILE__, __LINE__,__func__,(int)B,A);fflush(stdout); } while (0)60#define WATCHPOINT_STRING_LENGTH(A,B) do { fprintf(stderr, "\nWATCHPOINT %s:%d (%s) %.*s\n", __FILE__, __LINE__,__func__,(int)B,A);fflush(stdout); } while (0)
61#define WATCHPOINT_NUMBER(A) do { fprintf(stderr, "\nWATCHPOINT %s:%d (%s) %zu\n", __FILE__, __LINE__,__func__,(size_t)(A));fflush(stdout); } while (0)61#define WATCHPOINT_NUMBER(A) do { fprintf(stderr, "\nWATCHPOINT %s:%d (%s) %lu\n", __FILE__, __LINE__,__func__,(long unsigned int)(A));fflush(stdout); } while (0)
62#define WATCHPOINT_LABELED_NUMBER(A,B) do { fprintf(stderr, "\nWATCHPOINT %s:%d (%s) %s:%zu\n", __FILE__, __LINE__,__func__,(A),(size_t)(B));fflush(stdout); } while (0)62#define WATCHPOINT_LABELED_NUMBER(A,B) do { fprintf(stderr, "\nWATCHPOINT %s:%d (%s) %s:%lu\n", __FILE__, __LINE__,__func__,(A),(long unsigned int)(B));fflush(stdout); } while (0)
63#define WATCHPOINT_IF_LABELED_NUMBER(A,B,C) do { if(A) {fprintf(stderr, "\nWATCHPOINT %s:%d (%s) %s:%zu\n", __FILE__, __LINE__,__func__,(B),(size_t)(C));fflush(stdout);} } while (0)63#define WATCHPOINT_IF_LABELED_NUMBER(A,B,C) do { if(A) {fprintf(stderr, "\nWATCHPOINT %s:%d (%s) %s:%lu\n", __FILE__, __LINE__,__func__,(B),(long unsigned int)(C));fflush(stdout);} } while (0)
64#define WATCHPOINT_ERRNO(A) do { fprintf(stderr, "\nWATCHPOINT %s:%d (%s) %s\n", __FILE__, __LINE__,__func__, strerror(A));fflush(stdout); } while (0)64#define WATCHPOINT_ERRNO(A) do { fprintf(stderr, "\nWATCHPOINT %s:%d (%s) %s\n", __FILE__, __LINE__,__func__, strerror(A));fflush(stdout); } while (0)
65#define WATCHPOINT_ASSERT_PRINT(A,B,C) do { if(!(A)){fprintf(stderr, "\nWATCHPOINT ASSERT %s:%d (%s) ", __FILE__, __LINE__,__func__);fprintf(stderr, (B),(C));fprintf(stderr,"\n");fflush(stdout); libmemcached_stack_dump(); } assert((A)); } while (0)65#define WATCHPOINT_ASSERT_PRINT(A,B,C) do { if(!(A)){fprintf(stderr, "\nWATCHPOINT ASSERT %s:%d (%s) ", __FILE__, __LINE__,__func__);fprintf(stderr, (B),(C));fprintf(stderr,"\n");fflush(stdout); libmemcached_stack_dump(); } assert((A)); } while (0)
66#define WATCHPOINT_ASSERT(A) do { if (! (A)) {libmemcached_stack_dump();} assert((A)); } while (0)66#define WATCHPOINT_ASSERT(A) do { if (! (A)) {libmemcached_stack_dump();} assert((A)); } while (0)
6767
=== modified file 'poll/poll.c'
--- poll/poll.c 2010-07-28 18:48:00 +0000
+++ poll/poll.c 2011-01-13 03:40:43 +0000
@@ -9,19 +9,27 @@
9 *9 *
10 */10 */
11#include "config.h"11#include "config.h"
12#include <sys/time.h>12
13#include <strings.h>13#ifdef WIN32
14# include <ws2tcpip.h>
15#else
16# include <sys/time.h>
17# include <strings.h>
18#endif
1419
15int poll(struct pollfd fds[], nfds_t nfds, int tmo)20int poll(struct pollfd fds[], nfds_t nfds, int tmo)
16{21{
22 int maxfd= 0, ret;
23 nfds_t x;
24 struct timeval timeout;
25 struct timeval *tp;
26
17 fd_set readfds, writefds, errorfds;27 fd_set readfds, writefds, errorfds;
18 FD_ZERO(&readfds);28 FD_ZERO(&readfds);
19 FD_ZERO(&writefds);29 FD_ZERO(&writefds);
20 FD_ZERO(&errorfds);30 FD_ZERO(&errorfds);
2131
22 int maxfd= 0;32 for (x= 0; x < nfds; ++x)
23
24 for (nfds_t x= 0; x < nfds; ++x)
25 {33 {
26 if (fds[x].events & (POLLIN | POLLOUT))34 if (fds[x].events & (POLLIN | POLLOUT))
27 {35 {
@@ -42,21 +50,22 @@
42 }50 }
43 }51 }
4452
45 struct timeval timeout= { .tv_sec = tmo / 1000,53 timeout.tv_sec = tmo / 1000;
46 .tv_usec= (tmo % 1000) * 1000 };54 timeout.tv_usec= (tmo % 1000) * 1000;
47 struct timeval *tp= &timeout;55
56 tp= &timeout;
48 if (tmo == -1)57 if (tmo == -1)
49 {58 {
50 tp= NULL;59 tp= NULL;
51 }60 }
52 int ret= select(maxfd + 1, &readfds, &writefds, &errorfds, tp);61 ret= select(maxfd + 1, &readfds, &writefds, &errorfds, tp);
53 if (ret <= 0)62 if (ret <= 0)
54 {63 {
55 return ret;64 return ret;
56 }65 }
5766
58 /* Iterate through all of them because I need to clear the revent map */67 /* Iterate through all of them because I need to clear the revent map */
59 for (nfds_t x= 0; x < nfds; ++x)68 for (x= 0; x < nfds; ++x)
60 {69 {
61 fds[x].revents= 0;70 fds[x].revents= 0;
62 if (FD_ISSET(fds[x].fd, &readfds))71 if (FD_ISSET(fds[x].fd, &readfds))
6372
=== added file 'win32/common.vsprops'
--- win32/common.vsprops 1970-01-01 00:00:00 +0000
+++ win32/common.vsprops 2011-01-13 03:40:43 +0000
@@ -0,0 +1,25 @@
1<?xml version="1.0" encoding="gb2312"?>
2<VisualStudioPropertySheet
3 ProjectType="Visual C++"
4 Version="8.00"
5 Name="essential"
6 CharacterSet="2"
7 >
8 <Tool
9 Name="VCCLCompilerTool"
10 AdditionalIncludeDirectories="..;..\win32;"
11 PreprocessorDefinitions="WIN32;_WINDOWS;_USRDLL;LIBMEMCACHED_STATIC"
12 MinimalRebuild="true"
13 RuntimeLibrary="3"
14 WarningLevel="3"
15 DebugInformationFormat="4"
16 />
17 <Tool
18 Name="VCLinkerTool"
19 AdditionalDependencies="ws2_32.lib libmemcached-win32.lib"
20 AdditionalLibraryDirectories="&quot;$(OutDir)&quot;"
21 GenerateDebugInformation="true"
22 TargetMachine="1"
23 />
24</VisualStudioPropertySheet>
25
0\ No newline at end of file26\ No newline at end of file
127
=== added file 'win32/debug.vsprops'
--- win32/debug.vsprops 1970-01-01 00:00:00 +0000
+++ win32/debug.vsprops 2011-01-13 03:40:43 +0000
@@ -0,0 +1,12 @@
1<?xml version="1.0" encoding="gb2312"?>
2<VisualStudioPropertySheet
3 ProjectType="Visual C++"
4 Version="8.00"
5 Name="essential"
6 CharacterSet="2"
7 >
8 <Tool
9 Name="VCCLCompilerTool"
10 PreprocessorDefinitions="_DEBUG"
11 />
12</VisualStudioPropertySheet>
0\ No newline at end of file13\ No newline at end of file
114
=== added file 'win32/getopt.c'
--- win32/getopt.c 1970-01-01 00:00:00 +0000
+++ win32/getopt.c 2011-01-13 03:40:43 +0000
@@ -0,0 +1,1067 @@
1/* Getopt for GNU.
2 NOTE: getopt is now part of the C library, so if you don't know what
3 "Keep this file name-space clean" means, talk to drepper@gnu.org
4 before changing it!
5
6 Copyright (C) 1987, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 2000
7 Free Software Foundation, Inc.
8
9 The GNU C Library is free software; you can redistribute it and/or
10 modify it under the terms of the GNU Library General Public License as
11 published by the Free Software Foundation; either version 2 of the
12 License, or (at your option) any later version.
13
14 The GNU C Library is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Library General Public License for more details.
18
19 You should have received a copy of the GNU Library General Public
20 License along with the GNU C Library; see the file COPYING.LIB. If not,
21 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 Boston, MA 02111-1307, USA. */
23
024
25/* This tells Alpha OSF/1 not to define a getopt prototype in <stdio.h>.
26 Ditto for AIX 3.2 and <stdlib.h>. */
27#ifndef _NO_PROTO
28# define _NO_PROTO
29#endif
30
31#ifdef HAVE_CONFIG_H
32# include <config.h>
33#endif
34
35#if !defined __STDC__ || !__STDC__
36/* This is a separate conditional since some stdc systems
37 reject `defined (const)'. */
38# ifndef const
39# define const
40# endif
41#endif
42
43#include <stdio.h>
44
45/* Comment out all this code if we are using the GNU C Library, and are not
46 actually compiling the library itself. This code is part of the GNU C
47 Library, but also included in many other GNU distributions. Compiling
48 and linking in this code is a waste when using the GNU C library
49 (especially if it is a shared library). Rather than having every GNU
50 program understand `configure --with-gnu-libc' and omit the object files,
51 it is simpler to just do this in the source for each such file. */
52
53#define GETOPT_INTERFACE_VERSION 2
54#if !defined _LIBC && defined __GLIBC__ && __GLIBC__ >= 2
55# include <gnu-versions.h>
56# if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION
57# define ELIDE_CODE
58# endif
59#endif
60
61#ifndef ELIDE_CODE
62
63
64/* This needs to come after some library #include
65 to get __GNU_LIBRARY__ defined. */
66#ifdef __GNU_LIBRARY__
67/* Don't include stdlib.h for non-GNU C libraries because some of them
68 contain conflicting prototypes for getopt. */
69# include <stdlib.h>
70# include <unistd.h>
71#endif /* GNU C library. */
72
73#ifdef VMS
74# include <unixlib.h>
75# if HAVE_STRING_H - 0
76# include <string.h>
77# endif
78#endif
79
80#ifdef WIN32
81# define HAVE_STRING_H 1
82#endif
83
84#ifndef _
85/* This is for other GNU distributions with internationalized messages.
86 When compiling libc, the _ macro is predefined. */
87# ifdef HAVE_LIBINTL_H
88# include <libintl.h>
89# define _(msgid) gettext (msgid)
90# else
91# define _(msgid) (msgid)
92# endif
93#endif
94
95/* This version of `getopt' appears to the caller like standard Unix `getopt'
96 but it behaves differently for the user, since it allows the user
97 to intersperse the options with the other arguments.
98
99 As `getopt' works, it permutes the elements of ARGV so that,
100 when it is done, all the options precede everything else. Thus
101 all application programs are extended to handle flexible argument order.
102
103 Setting the environment variable POSIXLY_CORRECT disables permutation.
104 Then the behavior is completely standard.
105
106 GNU application programs can use a third alternative mode in which
107 they can distinguish the relative order of options and other arguments. */
108
109#include "getopt.h"
110
111/* For communication from `getopt' to the caller.
112 When `getopt' finds an option that takes an argument,
113 the argument value is returned here.
114 Also, when `ordering' is RETURN_IN_ORDER,
115 each non-option ARGV-element is returned here. */
116
117char *optarg;
118
119/* Index in ARGV of the next element to be scanned.
120 This is used for communication to and from the caller
121 and for communication between successive calls to `getopt'.
122
123 On entry to `getopt', zero means this is the first call; initialize.
124
125 When `getopt' returns -1, this is the index of the first of the
126 non-option elements that the caller should itself scan.
127
128 Otherwise, `optind' communicates from one call to the next
129 how much of ARGV has been scanned so far. */
130
131/* 1003.2 says this must be 1 before any call. */
132int optind = 1;
133
134/* Formerly, initialization of getopt depended on optind==0, which
135 causes problems with re-calling getopt as programs generally don't
136 know that. */
137
138int __getopt_initialized;
139
140/* The next char to be scanned in the option-element
141 in which the last option character we returned was found.
142 This allows us to pick up the scan where we left off.
143
144 If this is zero, or a null string, it means resume the scan
145 by advancing to the next ARGV-element. */
146
147static char *nextchar;
148
149/* Callers store zero here to inhibit the error message
150 for unrecognized options. */
151
152int opterr = 1;
153
154/* Set to an option character which was unrecognized.
155 This must be initialized on some systems to avoid linking in the
156 system's own getopt implementation. */
157
158int optopt = '?';
159
160/* Describe how to deal with options that follow non-option ARGV-elements.
161
162 If the caller did not specify anything,
163 the default is REQUIRE_ORDER if the environment variable
164 POSIXLY_CORRECT is defined, PERMUTE otherwise.
165
166 REQUIRE_ORDER means don't recognize them as options;
167 stop option processing when the first non-option is seen.
168 This is what Unix does.
169 This mode of operation is selected by either setting the environment
170 variable POSIXLY_CORRECT, or using `+' as the first character
171 of the list of option characters.
172
173 PERMUTE is the default. We permute the contents of ARGV as we scan,
174 so that eventually all the non-options are at the end. This allows options
175 to be given in any order, even with programs that were not written to
176 expect this.
177
178 RETURN_IN_ORDER is an option available to programs that were written
179 to expect options and other ARGV-elements in any order and that care about
180 the ordering of the two. We describe each non-option ARGV-element
181 as if it were the argument of an option with character code 1.
182 Using `-' as the first character of the list of option characters
183 selects this mode of operation.
184
185 The special argument `--' forces an end of option-scanning regardless
186 of the value of `ordering'. In the case of RETURN_IN_ORDER, only
187 `--' can cause `getopt' to return -1 with `optind' != ARGC. */
188
189static enum
190{
191 REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER
192} ordering;
193
194/* Value of POSIXLY_CORRECT environment variable. */
195static char *posixly_correct;
196
1197
198#ifdef __GNU_LIBRARY__
199/* We want to avoid inclusion of string.h with non-GNU libraries
200 because there are many ways it can cause trouble.
201 On some systems, it contains special magic macros that don't work
202 in GCC. */
203# include <string.h>
204# define my_index strchr
205#else
206
207# if HAVE_STRING_H
208# include <string.h>
209# else
210# include <strings.h>
211# endif
212
213/* Avoid depending on library functions or files
214 whose names are inconsistent. */
215
216#ifndef getenv
217extern char *getenv ();
218#endif
219
220static char *
221my_index (str, chr)
222 const char *str;
223 int chr;
224{
225 while (*str)
226 {
227 if (*str == chr)
228 return (char *) str;
229 str++;
230 }
231 return 0;
232}
233
234/* If using GCC, we can safely declare strlen this way.
235 If not using GCC, it is ok not to declare it. */
236#ifdef __GNUC__
237/* Note that Motorola Delta 68k R3V7 comes with GCC but not stddef.h.
238 That was relevant to code that was here before. */
239# if (!defined __STDC__ || !__STDC__) && !defined strlen
240/* gcc with -traditional declares the built-in strlen to return int,
241 and has done so at least since version 2.4.5. -- rms. */
242extern int strlen (const char *);
243# endif /* not __STDC__ */
244#endif /* __GNUC__ */
245
246#endif /* not __GNU_LIBRARY__ */
247
2248
249/* Handle permutation of arguments. */
250
251/* Describe the part of ARGV that contains non-options that have
252 been skipped. `first_nonopt' is the index in ARGV of the first of them;
253 `last_nonopt' is the index after the last of them. */
254
255static int first_nonopt;
256static int last_nonopt;
257
258#ifdef _LIBC
259/* Bash 2.0 gives us an environment variable containing flags
260 indicating ARGV elements that should not be considered arguments. */
261
262/* Defined in getopt_init.c */
263extern char *__getopt_nonoption_flags;
264
265static int nonoption_flags_max_len;
266static int nonoption_flags_len;
267
268static int original_argc;
269static char *const *original_argv;
270
271/* Make sure the environment variable bash 2.0 puts in the environment
272 is valid for the getopt call we must make sure that the ARGV passed
273 to getopt is that one passed to the process. */
274static void
275__attribute__ ((unused))
276store_args_and_env (int argc, char *const *argv)
277{
278 /* XXX This is no good solution. We should rather copy the args so
279 that we can compare them later. But we must not use malloc(3). */
280 original_argc = argc;
281 original_argv = argv;
282}
283# ifdef text_set_element
284text_set_element (__libc_subinit, store_args_and_env);
285# endif /* text_set_element */
286
287# define SWAP_FLAGS(ch1, ch2) \
288 if (nonoption_flags_len > 0) \
289 { \
290 char __tmp = __getopt_nonoption_flags[ch1]; \
291 __getopt_nonoption_flags[ch1] = __getopt_nonoption_flags[ch2]; \
292 __getopt_nonoption_flags[ch2] = __tmp; \
293 }
294#else /* !_LIBC */
295# define SWAP_FLAGS(ch1, ch2)
296#endif /* _LIBC */
297
298/* Exchange two adjacent subsequences of ARGV.
299 One subsequence is elements [first_nonopt,last_nonopt)
300 which contains all the non-options that have been skipped so far.
301 The other is elements [last_nonopt,optind), which contains all
302 the options processed since those non-options were skipped.
303
304 `first_nonopt' and `last_nonopt' are relocated so that they describe
305 the new indices of the non-options in ARGV after they are moved. */
306
307#if defined __STDC__ && __STDC__
308static void exchange (char **);
309#endif
310
311static void
312exchange (argv)
313 char **argv;
314{
315 int bottom = first_nonopt;
316 int middle = last_nonopt;
317 int top = optind;
318 char *tem;
319
320 /* Exchange the shorter segment with the far end of the longer segment.
321 That puts the shorter segment into the right place.
322 It leaves the longer segment in the right place overall,
323 but it consists of two parts that need to be swapped next. */
324
325#ifdef _LIBC
326 /* First make sure the handling of the `__getopt_nonoption_flags'
327 string can work normally. Our top argument must be in the range
328 of the string. */
329 if (nonoption_flags_len > 0 && top >= nonoption_flags_max_len)
330 {
331 /* We must extend the array. The user plays games with us and
332 presents new arguments. */
333 char *new_str = malloc (top + 1);
334 if (new_str == NULL)
335 nonoption_flags_len = nonoption_flags_max_len = 0;
336 else
337 {
338 memset (__mempcpy (new_str, __getopt_nonoption_flags,
339 nonoption_flags_max_len),
340 '\0', top + 1 - nonoption_flags_max_len);
341 nonoption_flags_max_len = top + 1;
342 __getopt_nonoption_flags = new_str;
343 }
344 }
345#endif
346
347 while (top > middle && middle > bottom)
348 {
349 if (top - middle > middle - bottom)
350 {
351 /* Bottom segment is the short one. */
352 int len = middle - bottom;
353 register int i;
354
355 /* Swap it with the top part of the top segment. */
356 for (i = 0; i < len; i++)
357 {
358 tem = argv[bottom + i];
359 argv[bottom + i] = argv[top - (middle - bottom) + i];
360 argv[top - (middle - bottom) + i] = tem;
361 SWAP_FLAGS (bottom + i, top - (middle - bottom) + i);
362 }
363 /* Exclude the moved bottom segment from further swapping. */
364 top -= len;
365 }
366 else
367 {
368 /* Top segment is the short one. */
369 int len = top - middle;
370 register int i;
371
372 /* Swap it with the bottom part of the bottom segment. */
373 for (i = 0; i < len; i++)
374 {
375 tem = argv[bottom + i];
376 argv[bottom + i] = argv[middle + i];
377 argv[middle + i] = tem;
378 SWAP_FLAGS (bottom + i, middle + i);
379 }
380 /* Exclude the moved top segment from further swapping. */
381 bottom += len;
382 }
383 }
384
385 /* Update records for the slots the non-options now occupy. */
386
387 first_nonopt += (optind - last_nonopt);
388 last_nonopt = optind;
389}
390
391/* Initialize the internal data when the first call is made. */
392
393#if defined __STDC__ && __STDC__
394static const char *_getopt_initialize (int, char *const *, const char *);
395#endif
396static const char *
397_getopt_initialize (argc, argv, optstring)
398 int argc;
399 char *const *argv;
400 const char *optstring;
401{
402 /* Start processing options with ARGV-element 1 (since ARGV-element 0
403 is the program name); the sequence of previously skipped
404 non-option ARGV-elements is empty. */
405
406 first_nonopt = last_nonopt = optind;
407
408 nextchar = NULL;
409
410 posixly_correct = getenv ("POSIXLY_CORRECT");
411
412 /* Determine how to handle the ordering of options and nonoptions. */
413
414 if (optstring[0] == '-')
415 {
416 ordering = RETURN_IN_ORDER;
417 ++optstring;
418 }
419 else if (optstring[0] == '+')
420 {
421 ordering = REQUIRE_ORDER;
422 ++optstring;
423 }
424 else if (posixly_correct != NULL)
425 ordering = REQUIRE_ORDER;
426 else
427 ordering = PERMUTE;
428
429#ifdef _LIBC
430 if (posixly_correct == NULL
431 && argc == original_argc && argv == original_argv)
432 {
433 if (nonoption_flags_max_len == 0)
434 {
435 if (__getopt_nonoption_flags == NULL
436 || __getopt_nonoption_flags[0] == '\0')
437 nonoption_flags_max_len = -1;
438 else
439 {
440 const char *orig_str = __getopt_nonoption_flags;
441 int len = nonoption_flags_max_len = strlen (orig_str);
442 if (nonoption_flags_max_len < argc)
443 nonoption_flags_max_len = argc;
444 __getopt_nonoption_flags =
445 (char *) malloc (nonoption_flags_max_len);
446 if (__getopt_nonoption_flags == NULL)
447 nonoption_flags_max_len = -1;
448 else
449 memset (__mempcpy (__getopt_nonoption_flags, orig_str, len),
450 '\0', nonoption_flags_max_len - len);
451 }
452 }
453 nonoption_flags_len = nonoption_flags_max_len;
454 }
455 else
456 nonoption_flags_len = 0;
457#endif
458
459 return optstring;
460}
461
3462
463/* Scan elements of ARGV (whose length is ARGC) for option characters
464 given in OPTSTRING.
465
466 If an element of ARGV starts with '-', and is not exactly "-" or "--",
467 then it is an option element. The characters of this element
468 (aside from the initial '-') are option characters. If `getopt'
469 is called repeatedly, it returns successively each of the option characters
470 from each of the option elements.
471
472 If `getopt' finds another option character, it returns that character,
473 updating `optind' and `nextchar' so that the next call to `getopt' can
474 resume the scan with the following option character or ARGV-element.
475
476 If there are no more option characters, `getopt' returns -1.
477 Then `optind' is the index in ARGV of the first ARGV-element
478 that is not an option. (The ARGV-elements have been permuted
479 so that those that are not options now come last.)
480
481 OPTSTRING is a string containing the legitimate option characters.
482 If an option character is seen that is not listed in OPTSTRING,
483 return '?' after printing an error message. If you set `opterr' to
484 zero, the error message is suppressed but we still return '?'.
485
486 If a char in OPTSTRING is followed by a colon, that means it wants an arg,
487 so the following text in the same ARGV-element, or the text of the following
488 ARGV-element, is returned in `optarg'. Two colons mean an option that
489 wants an optional arg; if there is text in the current ARGV-element,
490 it is returned in `optarg', otherwise `optarg' is set to zero.
491
492 If OPTSTRING starts with `-' or `+', it requests different methods of
493 handling the non-option ARGV-elements.
494 See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above.
495
496 Long-named options begin with `--' instead of `-'.
497 Their names may be abbreviated as long as the abbreviation is unique
498 or is an exact match for some defined option. If they have an
499 argument, it follows the option name in the same ARGV-element, separated
500 from the option name by a `=', or else the in next ARGV-element.
501 When `getopt' finds a long-named option, it returns 0 if that option's
502 `flag' field is nonzero, the value of the option's `val' field
503 if the `flag' field is zero.
504
505 The elements of ARGV aren't really const, because we permute them.
506 But we pretend they're const in the prototype to be compatible
507 with other systems.
508
509 LONGOPTS is a vector of `struct option' terminated by an
510 element containing a name which is zero.
511
512 LONGIND returns the index in LONGOPT of the long-named option found.
513 It is only valid when a long-named option has been found by the most
514 recent call.
515
516 If LONG_ONLY is nonzero, '-' as well as '--' can introduce
517 long-named options. */
518
519int
520_getopt_internal (argc, argv, optstring, longopts, longind, long_only)
521 int argc;
522 char *const *argv;
523 const char *optstring;
524 const struct option *longopts;
525 int *longind;
526 int long_only;
527{
528 int print_errors = opterr;
529 if (optstring[0] == ':')
530 print_errors = 0;
531
532 optarg = NULL;
533
534 if (optind == 0 || !__getopt_initialized)
535 {
536 if (optind == 0)
537 optind = 1; /* Don't scan ARGV[0], the program name. */
538 optstring = _getopt_initialize (argc, argv, optstring);
539 __getopt_initialized = 1;
540 }
541
542 /* Test whether ARGV[optind] points to a non-option argument.
543 Either it does not have option syntax, or there is an environment flag
544 from the shell indicating it is not an option. The later information
545 is only used when the used in the GNU libc. */
546#ifdef _LIBC
547# define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0' \
548 || (optind < nonoption_flags_len \
549 && __getopt_nonoption_flags[optind] == '1'))
550#else
551# define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0')
552#endif
553
554 if (nextchar == NULL || *nextchar == '\0')
555 {
556 /* Advance to the next ARGV-element. */
557
558 /* Give FIRST_NONOPT & LAST_NONOPT rational values if OPTIND has been
559 moved back by the user (who may also have changed the arguments). */
560 if (last_nonopt > optind)
561 last_nonopt = optind;
562 if (first_nonopt > optind)
563 first_nonopt = optind;
564
565 if (ordering == PERMUTE)
566 {
567 /* If we have just processed some options following some non-options,
568 exchange them so that the options come first. */
569
570 if (first_nonopt != last_nonopt && last_nonopt != optind)
571 exchange ((char **) argv);
572 else if (last_nonopt != optind)
573 first_nonopt = optind;
574
575 /* Skip any additional non-options
576 and extend the range of non-options previously skipped. */
577
578 while (optind < argc && NONOPTION_P)
579 optind++;
580 last_nonopt = optind;
581 }
582
583 /* The special ARGV-element `--' means premature end of options.
584 Skip it like a null option,
585 then exchange with previous non-options as if it were an option,
586 then skip everything else like a non-option. */
587
588 if (optind != argc && !strcmp (argv[optind], "--"))
589 {
590 optind++;
591
592 if (first_nonopt != last_nonopt && last_nonopt != optind)
593 exchange ((char **) argv);
594 else if (first_nonopt == last_nonopt)
595 first_nonopt = optind;
596 last_nonopt = argc;
597
598 optind = argc;
599 }
600
601 /* If we have done all the ARGV-elements, stop the scan
602 and back over any non-options that we skipped and permuted. */
603
604 if (optind == argc)
605 {
606 /* Set the next-arg-index to point at the non-options
607 that we previously skipped, so the caller will digest them. */
608 if (first_nonopt != last_nonopt)
609 optind = first_nonopt;
610 return -1;
611 }
612
613 /* If we have come to a non-option and did not permute it,
614 either stop the scan or describe it to the caller and pass it by. */
615
616 if (NONOPTION_P)
617 {
618 if (ordering == REQUIRE_ORDER)
619 return -1;
620 optarg = argv[optind++];
621 return 1;
622 }
623
624 /* We have found another option-ARGV-element.
625 Skip the initial punctuation. */
626
627 nextchar = (argv[optind] + 1
628 + (longopts != NULL && argv[optind][1] == '-'));
629 }
630
631 /* Decode the current option-ARGV-element. */
632
633 /* Check whether the ARGV-element is a long option.
634
635 If long_only and the ARGV-element has the form "-f", where f is
636 a valid short option, don't consider it an abbreviated form of
637 a long option that starts with f. Otherwise there would be no
638 way to give the -f short option.
639
640 On the other hand, if there's a long option "fubar" and
641 the ARGV-element is "-fu", do consider that an abbreviation of
642 the long option, just like "--fu", and not "-f" with arg "u".
643
644 This distinction seems to be the most useful approach. */
645
646 if (longopts != NULL
647 && (argv[optind][1] == '-'
648 || (long_only && (argv[optind][2] || !my_index (optstring, argv[optind][1])))))
649 {
650 char *nameend;
651 const struct option *p;
652 const struct option *pfound = NULL;
653 int exact = 0;
654 int ambig = 0;
655 int indfound = -1;
656 int option_index;
657
658 for (nameend = nextchar; *nameend && *nameend != '='; nameend++)
659 /* Do nothing. */ ;
660
661 /* Test all long options for either exact match
662 or abbreviated matches. */
663 for (p = longopts, option_index = 0; p->name; p++, option_index++)
664 if (!strncmp (p->name, nextchar, nameend - nextchar))
665 {
666 if ((unsigned int) (nameend - nextchar)
667 == (unsigned int) strlen (p->name))
668 {
669 /* Exact match found. */
670 pfound = p;
671 indfound = option_index;
672 exact = 1;
673 break;
674 }
675 else if (pfound == NULL)
676 {
677 /* First nonexact match found. */
678 pfound = p;
679 indfound = option_index;
680 }
681 else
682 /* Second or later nonexact match found. */
683 ambig = 1;
684 }
685
686 if (ambig && !exact)
687 {
688 if (print_errors)
689 fprintf (stderr, _("%s: option `%s' is ambiguous\n"),
690 argv[0], argv[optind]);
691 nextchar += strlen (nextchar);
692 optind++;
693 optopt = 0;
694 return '?';
695 }
696
697 if (pfound != NULL)
698 {
699 option_index = indfound;
700 optind++;
701 if (*nameend)
702 {
703 /* Don't test has_arg with >, because some C compilers don't
704 allow it to be used on enums. */
705 if (pfound->has_arg)
706 optarg = nameend + 1;
707 else
708 {
709 if (print_errors)
710 {
711 if (argv[optind - 1][1] == '-')
712 /* --option */
713 fprintf (stderr,
714 _("%s: option `--%s' doesn't allow an argument\n"),
715 argv[0], pfound->name);
716 else
717 /* +option or -option */
718 fprintf (stderr,
719 _("%s: option `%c%s' doesn't allow an argument\n"),
720 argv[0], argv[optind - 1][0], pfound->name);
721 }
722
723 nextchar += strlen (nextchar);
724
725 optopt = pfound->val;
726 return '?';
727 }
728 }
729 else if (pfound->has_arg == 1)
730 {
731 if (optind < argc)
732 optarg = argv[optind++];
733 else
734 {
735 if (print_errors)
736 fprintf (stderr,
737 _("%s: option `%s' requires an argument\n"),
738 argv[0], argv[optind - 1]);
739 nextchar += strlen (nextchar);
740 optopt = pfound->val;
741 return optstring[0] == ':' ? ':' : '?';
742 }
743 }
744 nextchar += strlen (nextchar);
745 if (longind != NULL)
746 *longind = option_index;
747 if (pfound->flag)
748 {
749 *(pfound->flag) = pfound->val;
750 return 0;
751 }
752 return pfound->val;
753 }
754
755 /* Can't find it as a long option. If this is not getopt_long_only,
756 or the option starts with '--' or is not a valid short
757 option, then it's an error.
758 Otherwise interpret it as a short option. */
759 if (!long_only || argv[optind][1] == '-'
760 || my_index (optstring, *nextchar) == NULL)
761 {
762 if (print_errors)
763 {
764 if (argv[optind][1] == '-')
765 /* --option */
766 fprintf (stderr, _("%s: unrecognized option `--%s'\n"),
767 argv[0], nextchar);
768 else
769 /* +option or -option */
770 fprintf (stderr, _("%s: unrecognized option `%c%s'\n"),
771 argv[0], argv[optind][0], nextchar);
772 }
773 nextchar = (char *) "";
774 optind++;
775 optopt = 0;
776 return '?';
777 }
778 }
779
780 /* Look at and handle the next short option-character. */
781
782 {
783 char c = *nextchar++;
784 char *temp = my_index (optstring, c);
785
786 /* Increment `optind' when we start to process its last character. */
787 if (*nextchar == '\0')
788 ++optind;
789
790 if (temp == NULL || c == ':')
791 {
792 if (print_errors)
793 {
794 if (posixly_correct)
795 /* 1003.2 specifies the format of this message. */
796 fprintf (stderr, _("%s: illegal option -- %c\n"),
797 argv[0], c);
798 else
799 fprintf (stderr, _("%s: invalid option -- %c\n"),
800 argv[0], c);
801 }
802 optopt = c;
803 return '?';
804 }
805 /* Convenience. Treat POSIX -W foo same as long option --foo */
806 if (temp[0] == 'W' && temp[1] == ';')
807 {
808 char *nameend;
809 const struct option *p;
810 const struct option *pfound = NULL;
811 int exact = 0;
812 int ambig = 0;
813 int indfound = 0;
814 int option_index;
815
816 /* This is an option that requires an argument. */
817 if (*nextchar != '\0')
818 {
819 optarg = nextchar;
820 /* If we end this ARGV-element by taking the rest as an arg,
821 we must advance to the next element now. */
822 optind++;
823 }
824 else if (optind == argc)
825 {
826 if (print_errors)
827 {
828 /* 1003.2 specifies the format of this message. */
829 fprintf (stderr, _("%s: option requires an argument -- %c\n"),
830 argv[0], c);
831 }
832 optopt = c;
833 if (optstring[0] == ':')
834 c = ':';
835 else
836 c = '?';
837 return c;
838 }
839 else
840 /* We already incremented `optind' once;
841 increment it again when taking next ARGV-elt as argument. */
842 optarg = argv[optind++];
843
844 /* optarg is now the argument, see if it's in the
845 table of longopts. */
846
847 for (nextchar = nameend = optarg; *nameend && *nameend != '='; nameend++)
848 /* Do nothing. */ ;
849
850 /* Test all long options for either exact match
851 or abbreviated matches. */
852 for (p = longopts, option_index = 0; p->name; p++, option_index++)
853 if (!strncmp (p->name, nextchar, nameend - nextchar))
854 {
855 if ((unsigned int) (nameend - nextchar) == strlen (p->name))
856 {
857 /* Exact match found. */
858 pfound = p;
859 indfound = option_index;
860 exact = 1;
861 break;
862 }
863 else if (pfound == NULL)
864 {
865 /* First nonexact match found. */
866 pfound = p;
867 indfound = option_index;
868 }
869 else
870 /* Second or later nonexact match found. */
871 ambig = 1;
872 }
873 if (ambig && !exact)
874 {
875 if (print_errors)
876 fprintf (stderr, _("%s: option `-W %s' is ambiguous\n"),
877 argv[0], argv[optind]);
878 nextchar += strlen (nextchar);
879 optind++;
880 return '?';
881 }
882 if (pfound != NULL)
883 {
884 option_index = indfound;
885 if (*nameend)
886 {
887 /* Don't test has_arg with >, because some C compilers don't
888 allow it to be used on enums. */
889 if (pfound->has_arg)
890 optarg = nameend + 1;
891 else
892 {
893 if (print_errors)
894 fprintf (stderr, _("\
895%s: option `-W %s' doesn't allow an argument\n"),
896 argv[0], pfound->name);
897
898 nextchar += strlen (nextchar);
899 return '?';
900 }
901 }
902 else if (pfound->has_arg == 1)
903 {
904 if (optind < argc)
905 optarg = argv[optind++];
906 else
907 {
908 if (print_errors)
909 fprintf (stderr,
910 _("%s: option `%s' requires an argument\n"),
911 argv[0], argv[optind - 1]);
912 nextchar += strlen (nextchar);
913 return optstring[0] == ':' ? ':' : '?';
914 }
915 }
916 nextchar += strlen (nextchar);
917 if (longind != NULL)
918 *longind = option_index;
919 if (pfound->flag)
920 {
921 *(pfound->flag) = pfound->val;
922 return 0;
923 }
924 return pfound->val;
925 }
926 nextchar = NULL;
927 return 'W'; /* Let the application handle it. */
928 }
929 if (temp[1] == ':')
930 {
931 if (temp[2] == ':')
932 {
933 /* This is an option that accepts an argument optionally. */
934 if (*nextchar != '\0')
935 {
936 optarg = nextchar;
937 optind++;
938 }
939 else
940 optarg = NULL;
941 nextchar = NULL;
942 }
943 else
944 {
945 /* This is an option that requires an argument. */
946 if (*nextchar != '\0')
947 {
948 optarg = nextchar;
949 /* If we end this ARGV-element by taking the rest as an arg,
950 we must advance to the next element now. */
951 optind++;
952 }
953 else if (optind == argc)
954 {
955 if (print_errors)
956 {
957 /* 1003.2 specifies the format of this message. */
958 fprintf (stderr,
959 _("%s: option requires an argument -- %c\n"),
960 argv[0], c);
961 }
962 optopt = c;
963 if (optstring[0] == ':')
964 c = ':';
965 else
966 c = '?';
967 }
968 else
969 /* We already incremented `optind' once;
970 increment it again when taking next ARGV-elt as argument. */
971 optarg = argv[optind++];
972 nextchar = NULL;
973 }
974 }
975 return c;
976 }
977}
978
979int
980getopt ( int argc, char *const *argv, const char *optstring)
981{
982 return _getopt_internal (argc, argv, optstring,
983 (const struct option *) 0,
984 (int *) 0,
985 0);
986}
987
988int getopt_long (int argc, char *const *argv, const char *optstring,
989 const struct option *longopts, int *longind)
990{
991 return _getopt_internal (argc, argv, optstring, longopts, longind, 0);
992}
993extern int getopt_long_only (int argc, char *const *argv, const char *optstring,
994 const struct option *longopts, int *longind)
995{
996 return _getopt_internal (argc, argv, optstring, longopts, longind, 1);
997}
998
999#endif /* Not ELIDE_CODE. */
1000
41001
1002#ifdef TEST
1003
1004/* Compile with -DTEST to make an executable for use in testing
1005 the above definition of `getopt'. */
1006
1007int
1008main (argc, argv)
1009 int argc;
1010 char **argv;
1011{
1012 int c;
1013 int digit_optind = 0;
1014
1015 while (1)
1016 {
1017 int this_option_optind = optind ? optind : 1;
1018
1019 c = getopt (argc, argv, "abc:d:0123456789");
1020 if (c == -1)
1021 break;
1022
1023 switch (c)
1024 {
1025 case '0':
1026 case '1':
1027 case '2':
1028 case '3':
1029 case '4':
1030 case '5':
1031 case '6':
1032 case '7':
1033 case '8':
1034 case '9':
1035 if (digit_optind != 0 && digit_optind != this_option_optind)
1036 printf ("digits occur in two different argv-elements.\n");
1037 digit_optind = this_option_optind;
1038 printf ("option %c\n", c);
1039 break;
1040
1041 case 'a':
1042 printf ("option a\n");
1043 break;
1044
1045 case 'b':
1046 printf ("option b\n");
1047 break;
1048
1049 case 'c':
1050 printf ("option c with value `%s'\n", optarg);
1051 break;
1052
1053 case '?':
1054 break;
1055
1056 default:
1057 printf ("?? getopt returned character code 0%o ??\n", c);
1058 }
1059 }
1060
1061 if (optind < argc)
1062 {
1063 printf ("non-option ARGV-elements: ");
1064 while (optind < argc)
1065 printf ("%s ", argv[optind++]);
1066 printf ("\n");
1067 }
1068
1069 exit (0);
1070}
1071
1072#endif /* TEST */
51073
=== added file 'win32/getopt.h'
--- win32/getopt.h 1970-01-01 00:00:00 +0000
+++ win32/getopt.h 2011-01-13 03:40:43 +0000
@@ -0,0 +1,173 @@
1/* Declarations for getopt.
2 Copyright (C) 1989,90,91,92,93,94,96,97,98 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License as
7 published by the Free Software Foundation; either version 2 of the
8 License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
14
15 You should have received a copy of the GNU General Public
16 License along with the GNU C Library; see the file COPYING. If not,
17 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. */
19
20#ifndef _GETOPT_H
21
22#ifndef __need_getopt
23# define _GETOPT_H 1
24#endif
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
30/* For communication from `getopt' to the caller.
31 When `getopt' finds an option that takes an argument,
32 the argument value is returned here.
33 Also, when `ordering' is RETURN_IN_ORDER,
34 each non-option ARGV-element is returned here. */
35
36extern char *optarg;
37
38/* Index in ARGV of the next element to be scanned.
39 This is used for communication to and from the caller
40 and for communication between successive calls to `getopt'.
41
42 On entry to `getopt', zero means this is the first call; initialize.
43
44 When `getopt' returns -1, this is the index of the first of the
45 non-option elements that the caller should itself scan.
46
47 Otherwise, `optind' communicates from one call to the next
48 how much of ARGV has been scanned so far. */
49
50extern int optind;
51
52/* Callers store zero here to inhibit the error message `getopt' prints
53 for unrecognized options. */
54
55extern int opterr;
56
57/* Set to an option character which was unrecognized. */
58
59extern int optopt;
60
61#ifndef __need_getopt
62/* Describe the long-named options requested by the application.
63 The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
64 of `struct option' terminated by an element containing a name which is
65 zero.
66
67 The field `has_arg' is:
68 no_argument (or 0) if the option does not take an argument,
69 required_argument (or 1) if the option requires an argument,
70 optional_argument (or 2) if the option takes an optional argument.
71
72 If the field `flag' is not NULL, it points to a variable that is set
73 to the value given in the field `val' when the option is found, but
74 left unchanged if the option is not found.
75
76 To have a long-named option do something other than set an `int' to
77 a compiled-in constant, such as set a value from `optarg', set the
78 option's `flag' field to zero and its `val' field to a nonzero
79 value (the equivalent single-letter option character, if there is
80 one). For long options that have a zero `flag' field, `getopt'
81 returns the contents of the `val' field. */
82
83struct option
84{
85# if defined __STDC__ && __STDC__
86 const char *name;
87# else
88 char *name;
89# endif
90 /* has_arg can't be an enum because some compilers complain about
91 type mismatches in all the code that assumes it is an int. */
92 int has_arg;
93 int *flag;
94 int val;
95};
96
97/* Names for the values of the `has_arg' field of `struct option'. */
98
99# define no_argument 0
100# define required_argument 1
101# define optional_argument 2
102#endif /* need getopt */
103
104
105/* Get definitions and prototypes for functions to process the
106 arguments in ARGV (ARGC of them, minus the program name) for
107 options given in OPTS.
108
109 Return the option character from OPTS just read. Return -1 when
110 there are no more options. For unrecognized options, or options
111 missing arguments, `optopt' is set to the option letter, and '?' is
112 returned.
113
114 The OPTS string is a list of characters which are recognized option
115 letters, optionally followed by colons, specifying that that letter
116 takes an argument, to be placed in `optarg'.
117
118 If a letter in OPTS is followed by two colons, its argument is
119 optional. This behavior is specific to the GNU `getopt'.
120
121 The argument `--' causes premature termination of argument
122 scanning, explicitly telling `getopt' that there are no more
123 options.
124
125 If OPTS begins with `--', then non-option arguments are treated as
126 arguments to the option '\0'. This behavior is specific to the GNU
127 `getopt'. */
128
129#if defined __STDC__ && __STDC__
130# ifdef __GNU_LIBRARY__
131/* Many other libraries have conflicting prototypes for getopt, with
132 differences in the consts, in stdlib.h. To avoid compilation
133 errors, only prototype getopt for the GNU C library. */
134extern int getopt (int __argc, char *const *__argv, const char *__shortopts);
135# else /* not __GNU_LIBRARY__ */
136extern int getopt ();
137# endif /* __GNU_LIBRARY__ */
138
139# ifndef __need_getopt
140extern int getopt_long (int __argc, char *const *__argv, const char *__shortopts,
141 const struct option *__longopts, int *__longind);
142extern int getopt_long_only (int __argc, char *const *__argv,
143 const char *__shortopts,
144 const struct option *__longopts, int *__longind);
145
146/* Internal only. Users should not call this directly. */
147extern int _getopt_internal (int __argc, char *const *__argv,
148 const char *__shortopts,
149 const struct option *__longopts, int *__longind,
150 int __long_only);
151# endif
152#else /* not __STDC__ */
153extern int
154getopt ( int argc, char *const *argv, const char *optstring);
155# ifndef __need_getopt
156extern int getopt_long (int argc, char *const *argv, const char *optstring,
157 const struct option *longopts, int *longind);
158extern int getopt_long_only (int argc, char *const *argv, const char *optstring,
159 const struct option *longopts, int *longind);
160
161extern int _getopt_internal (int argc, char *const *argv, const char *optstring,
162 const struct option *longopts, int *longind, int long_only);
163# endif
164#endif /* __STDC__ */
165
166#ifdef __cplusplus
167}
168#endif
169
170/* Make sure we later can get all the definitions and declarations. */
171#undef __need_getopt
172
173#endif /* getopt.h */
0174
=== added file 'win32/inttypes.h'
--- win32/inttypes.h 1970-01-01 00:00:00 +0000
+++ win32/inttypes.h 2011-01-13 03:40:43 +0000
@@ -0,0 +1,13 @@
1#pragma once
2
3typedef char int8_t;
4typedef unsigned char uint8_t;
5typedef short int16_t;
6typedef unsigned short uint16_t;
7typedef int int32_t;
8typedef unsigned int uint32_t;
9typedef __int64 int64_t;
10typedef unsigned __int64 uint64_t;
11
12typedef int ssize_t;
13typedef unsigned int size_t;
0\ No newline at end of file14\ No newline at end of file
115
=== added file 'win32/libmemcached.sln'
--- win32/libmemcached.sln 1970-01-01 00:00:00 +0000
+++ win32/libmemcached.sln 2011-01-13 03:40:43 +0000
@@ -0,0 +1,92 @@
1
2Microsoft Visual Studio Solution File, Format Version 10.00
3# Visual Studio 2008
4Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libmemcached-win32", "libmemcached.vcproj", "{3BF1DCB9-580A-4AC2-8F4E-141C8F578A99}"
5EndProject
6Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "memcapable", "memcapable.vcproj", "{9545B3E3-F6E1-4C3D-A7C3-BAB60D94A15A}"
7 ProjectSection(ProjectDependencies) = postProject
8 {3BF1DCB9-580A-4AC2-8F4E-141C8F578A99} = {3BF1DCB9-580A-4AC2-8F4E-141C8F578A99}
9 EndProjectSection
10EndProject
11Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "memcat", "memcat.vcproj", "{82BF1D3F-0090-456C-8E45-407E9B8DDF7B}"
12 ProjectSection(ProjectDependencies) = postProject
13 {3BF1DCB9-580A-4AC2-8F4E-141C8F578A99} = {3BF1DCB9-580A-4AC2-8F4E-141C8F578A99}
14 EndProjectSection
15EndProject
16Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "memcp", "memcp.vcproj", "{C590AC65-FFB1-4084-A850-A4893C1C93B0}"
17 ProjectSection(ProjectDependencies) = postProject
18 {3BF1DCB9-580A-4AC2-8F4E-141C8F578A99} = {3BF1DCB9-580A-4AC2-8F4E-141C8F578A99}
19 EndProjectSection
20EndProject
21Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "memdump", "memdump.vcproj", "{E0C217F1-E7B3-4B87-9067-B1B11CE1139D}"
22 ProjectSection(ProjectDependencies) = postProject
23 {3BF1DCB9-580A-4AC2-8F4E-141C8F578A99} = {3BF1DCB9-580A-4AC2-8F4E-141C8F578A99}
24 EndProjectSection
25EndProject
26Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "memerror", "memerror.vcproj", "{CD90B6B5-BAF7-49DC-A05F-C8606BC8F29B}"
27 ProjectSection(ProjectDependencies) = postProject
28 {3BF1DCB9-580A-4AC2-8F4E-141C8F578A99} = {3BF1DCB9-580A-4AC2-8F4E-141C8F578A99}
29 EndProjectSection
30EndProject
31Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "memflush", "memflush.vcproj", "{800FC200-ED8E-4191-944D-28B33540C62D}"
32 ProjectSection(ProjectDependencies) = postProject
33 {3BF1DCB9-580A-4AC2-8F4E-141C8F578A99} = {3BF1DCB9-580A-4AC2-8F4E-141C8F578A99}
34 EndProjectSection
35EndProject
36Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "memrm", "memrm.vcproj", "{656696BA-4EE2-41CE-B451-ADF82611701B}"
37 ProjectSection(ProjectDependencies) = postProject
38 {3BF1DCB9-580A-4AC2-8F4E-141C8F578A99} = {3BF1DCB9-580A-4AC2-8F4E-141C8F578A99}
39 EndProjectSection
40EndProject
41Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "memstat", "memstat.vcproj", "{9746CFE7-4AF2-458D-A216-FC56F5BA62F2}"
42 ProjectSection(ProjectDependencies) = postProject
43 {3BF1DCB9-580A-4AC2-8F4E-141C8F578A99} = {3BF1DCB9-580A-4AC2-8F4E-141C8F578A99}
44 EndProjectSection
45EndProject
46Global
47 GlobalSection(SolutionConfigurationPlatforms) = preSolution
48 Debug|Win32 = Debug|Win32
49 Release|Win32 = Release|Win32
50 EndGlobalSection
51 GlobalSection(ProjectConfigurationPlatforms) = postSolution
52 {3BF1DCB9-580A-4AC2-8F4E-141C8F578A99}.Debug|Win32.ActiveCfg = Debug|Win32
53 {3BF1DCB9-580A-4AC2-8F4E-141C8F578A99}.Debug|Win32.Build.0 = Debug|Win32
54 {3BF1DCB9-580A-4AC2-8F4E-141C8F578A99}.Release|Win32.ActiveCfg = Release|Win32
55 {3BF1DCB9-580A-4AC2-8F4E-141C8F578A99}.Release|Win32.Build.0 = Release|Win32
56 {9545B3E3-F6E1-4C3D-A7C3-BAB60D94A15A}.Debug|Win32.ActiveCfg = Debug|Win32
57 {9545B3E3-F6E1-4C3D-A7C3-BAB60D94A15A}.Debug|Win32.Build.0 = Debug|Win32
58 {9545B3E3-F6E1-4C3D-A7C3-BAB60D94A15A}.Release|Win32.ActiveCfg = Release|Win32
59 {9545B3E3-F6E1-4C3D-A7C3-BAB60D94A15A}.Release|Win32.Build.0 = Release|Win32
60 {82BF1D3F-0090-456C-8E45-407E9B8DDF7B}.Debug|Win32.ActiveCfg = Debug|Win32
61 {82BF1D3F-0090-456C-8E45-407E9B8DDF7B}.Debug|Win32.Build.0 = Debug|Win32
62 {82BF1D3F-0090-456C-8E45-407E9B8DDF7B}.Release|Win32.ActiveCfg = Release|Win32
63 {82BF1D3F-0090-456C-8E45-407E9B8DDF7B}.Release|Win32.Build.0 = Release|Win32
64 {C590AC65-FFB1-4084-A850-A4893C1C93B0}.Debug|Win32.ActiveCfg = Debug|Win32
65 {C590AC65-FFB1-4084-A850-A4893C1C93B0}.Debug|Win32.Build.0 = Debug|Win32
66 {C590AC65-FFB1-4084-A850-A4893C1C93B0}.Release|Win32.ActiveCfg = Release|Win32
67 {C590AC65-FFB1-4084-A850-A4893C1C93B0}.Release|Win32.Build.0 = Release|Win32
68 {E0C217F1-E7B3-4B87-9067-B1B11CE1139D}.Debug|Win32.ActiveCfg = Debug|Win32
69 {E0C217F1-E7B3-4B87-9067-B1B11CE1139D}.Debug|Win32.Build.0 = Debug|Win32
70 {E0C217F1-E7B3-4B87-9067-B1B11CE1139D}.Release|Win32.ActiveCfg = Release|Win32
71 {E0C217F1-E7B3-4B87-9067-B1B11CE1139D}.Release|Win32.Build.0 = Release|Win32
72 {CD90B6B5-BAF7-49DC-A05F-C8606BC8F29B}.Debug|Win32.ActiveCfg = Debug|Win32
73 {CD90B6B5-BAF7-49DC-A05F-C8606BC8F29B}.Debug|Win32.Build.0 = Debug|Win32
74 {CD90B6B5-BAF7-49DC-A05F-C8606BC8F29B}.Release|Win32.ActiveCfg = Release|Win32
75 {CD90B6B5-BAF7-49DC-A05F-C8606BC8F29B}.Release|Win32.Build.0 = Release|Win32
76 {800FC200-ED8E-4191-944D-28B33540C62D}.Debug|Win32.ActiveCfg = Debug|Win32
77 {800FC200-ED8E-4191-944D-28B33540C62D}.Debug|Win32.Build.0 = Debug|Win32
78 {800FC200-ED8E-4191-944D-28B33540C62D}.Release|Win32.ActiveCfg = Release|Win32
79 {800FC200-ED8E-4191-944D-28B33540C62D}.Release|Win32.Build.0 = Release|Win32
80 {656696BA-4EE2-41CE-B451-ADF82611701B}.Debug|Win32.ActiveCfg = Debug|Win32
81 {656696BA-4EE2-41CE-B451-ADF82611701B}.Debug|Win32.Build.0 = Debug|Win32
82 {656696BA-4EE2-41CE-B451-ADF82611701B}.Release|Win32.ActiveCfg = Release|Win32
83 {656696BA-4EE2-41CE-B451-ADF82611701B}.Release|Win32.Build.0 = Release|Win32
84 {9746CFE7-4AF2-458D-A216-FC56F5BA62F2}.Debug|Win32.ActiveCfg = Debug|Win32
85 {9746CFE7-4AF2-458D-A216-FC56F5BA62F2}.Debug|Win32.Build.0 = Debug|Win32
86 {9746CFE7-4AF2-458D-A216-FC56F5BA62F2}.Release|Win32.ActiveCfg = Release|Win32
87 {9746CFE7-4AF2-458D-A216-FC56F5BA62F2}.Release|Win32.Build.0 = Release|Win32
88 EndGlobalSection
89 GlobalSection(SolutionProperties) = preSolution
90 HideSolutionNode = FALSE
91 EndGlobalSection
92EndGlobal
093
=== added file 'win32/libmemcached.vcproj'
--- win32/libmemcached.vcproj 1970-01-01 00:00:00 +0000
+++ win32/libmemcached.vcproj 2011-01-13 03:40:43 +0000
@@ -0,0 +1,618 @@
1<?xml version="1.0" encoding="gb2312"?>
2<VisualStudioProject
3 ProjectType="Visual C++"
4 Version="9.00"
5 Name="libmemcached-win32"
6 ProjectGUID="{3BF1DCB9-580A-4AC2-8F4E-141C8F578A99}"
7 RootNamespace="libmemcachedwin32"
8 TargetFrameworkVersion="196613"
9 >
10 <Platforms>
11 <Platform
12 Name="Win32"
13 />
14 </Platforms>
15 <ToolFiles>
16 </ToolFiles>
17 <Configurations>
18 <Configuration
19 Name="Debug|Win32"
20 OutputDirectory="$(SolutionDir)$(ConfigurationName)"
21 IntermediateDirectory="$(ConfigurationName)"
22 ConfigurationType="4"
23 CharacterSet="2"
24 >
25 <Tool
26 Name="VCPreBuildEventTool"
27 />
28 <Tool
29 Name="VCCustomBuildTool"
30 />
31 <Tool
32 Name="VCXMLDataGeneratorTool"
33 />
34 <Tool
35 Name="VCWebServiceProxyGeneratorTool"
36 />
37 <Tool
38 Name="VCMIDLTool"
39 />
40 <Tool
41 Name="VCCLCompilerTool"
42 Optimization="0"
43 AdditionalIncludeDirectories="..;."
44 PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBMEMCACHED_STATIC"
45 MinimalRebuild="true"
46 BasicRuntimeChecks="3"
47 RuntimeLibrary="3"
48 WarningLevel="3"
49 DebugInformationFormat="4"
50 />
51 <Tool
52 Name="VCManagedResourceCompilerTool"
53 />
54 <Tool
55 Name="VCResourceCompilerTool"
56 />
57 <Tool
58 Name="VCPreLinkEventTool"
59 />
60 <Tool
61 Name="VCLibrarianTool"
62 />
63 <Tool
64 Name="VCALinkTool"
65 />
66 <Tool
67 Name="VCXDCMakeTool"
68 />
69 <Tool
70 Name="VCBscMakeTool"
71 />
72 <Tool
73 Name="VCFxCopTool"
74 />
75 <Tool
76 Name="VCPostBuildEventTool"
77 />
78 </Configuration>
79 <Configuration
80 Name="Release|Win32"
81 OutputDirectory="$(SolutionDir)$(ConfigurationName)"
82 IntermediateDirectory="$(ConfigurationName)"
83 ConfigurationType="4"
84 CharacterSet="2"
85 WholeProgramOptimization="1"
86 >
87 <Tool
88 Name="VCPreBuildEventTool"
89 />
90 <Tool
91 Name="VCCustomBuildTool"
92 />
93 <Tool
94 Name="VCXMLDataGeneratorTool"
95 />
96 <Tool
97 Name="VCWebServiceProxyGeneratorTool"
98 />
99 <Tool
100 Name="VCMIDLTool"
101 />
102 <Tool
103 Name="VCCLCompilerTool"
104 Optimization="2"
105 EnableIntrinsicFunctions="true"
106 AdditionalIncludeDirectories="..;."
107 PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBMEMCACHED_STATIC"
108 RuntimeLibrary="2"
109 EnableFunctionLevelLinking="true"
110 WarningLevel="3"
111 DebugInformationFormat="3"
112 />
113 <Tool
114 Name="VCManagedResourceCompilerTool"
115 />
116 <Tool
117 Name="VCResourceCompilerTool"
118 />
119 <Tool
120 Name="VCPreLinkEventTool"
121 />
122 <Tool
123 Name="VCLibrarianTool"
124 />
125 <Tool
126 Name="VCALinkTool"
127 />
128 <Tool
129 Name="VCXDCMakeTool"
130 />
131 <Tool
132 Name="VCBscMakeTool"
133 />
134 <Tool
135 Name="VCFxCopTool"
136 />
137 <Tool
138 Name="VCPostBuildEventTool"
139 />
140 </Configuration>
141 </Configurations>
142 <References>
143 </References>
144 <Files>
145 <Filter
146 Name="Source Files"
147 Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
148 UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
149 >
150 <File
151 RelativePath="..\libmemcached\allocators.c"
152 >
153 </File>
154 <File
155 RelativePath="..\libmemcached\analyze.c"
156 >
157 </File>
158 <File
159 RelativePath="..\libmemcached\auto.c"
160 >
161 </File>
162 <File
163 RelativePath="..\libmemcached\behavior.c"
164 >
165 </File>
166 <File
167 RelativePath="..\libmemcached\byteorder.c"
168 >
169 </File>
170 <File
171 RelativePath="..\libmemcached\callback.c"
172 >
173 </File>
174 <File
175 RelativePath="..\libmemcached\connect.c"
176 >
177 </File>
178 <File
179 RelativePath="..\libmemcached\delete.c"
180 >
181 </File>
182 <File
183 RelativePath="..\libmemcached\do.c"
184 >
185 </File>
186 <File
187 RelativePath="..\libmemcached\dump.c"
188 >
189 </File>
190 <File
191 RelativePath="..\libmemcached\fetch.c"
192 >
193 </File>
194 <File
195 RelativePath="..\libmemcached\flush.c"
196 >
197 </File>
198 <File
199 RelativePath="..\libmemcached\flush_buffers.c"
200 >
201 </File>
202 <File
203 RelativePath="..\libmemcached\get.c"
204 >
205 </File>
206 <File
207 RelativePath="..\libmemcached\hash.c"
208 >
209 </File>
210 <File
211 RelativePath="..\libmemcached\hosts.c"
212 >
213 </File>
214 <File
215 RelativePath="..\libmemcached\io.c"
216 >
217 </File>
218 <File
219 RelativePath="..\libmemcached\key.c"
220 >
221 </File>
222 <File
223 RelativePath="..\libmemcached\memcached.c"
224 >
225 </File>
226 <File
227 RelativePath="..\libmemcached\parse.c"
228 >
229 </File>
230 <File
231 RelativePath="..\libmemcached\purge.c"
232 >
233 </File>
234 <File
235 RelativePath="..\libmemcached\quit.c"
236 >
237 </File>
238 <File
239 RelativePath="..\libmemcached\response.c"
240 >
241 </File>
242 <File
243 RelativePath="..\libmemcached\result.c"
244 >
245 </File>
246 <File
247 RelativePath="..\libmemcached\sasl.c"
248 >
249 </File>
250 <File
251 RelativePath="..\libmemcached\server.c"
252 >
253 </File>
254 <File
255 RelativePath="..\libmemcached\server_list.c"
256 >
257 </File>
258 <File
259 RelativePath="..\libmemcached\stats.c"
260 >
261 </File>
262 <File
263 RelativePath="..\libmemcached\storage.c"
264 >
265 </File>
266 <File
267 RelativePath="..\libmemcached\strerror.c"
268 >
269 </File>
270 <File
271 RelativePath="..\libmemcached\string.c"
272 >
273 </File>
274 <File
275 RelativePath="..\libmemcached\verbosity.c"
276 >
277 </File>
278 <File
279 RelativePath="..\libmemcached\version.c"
280 >
281 </File>
282 <Filter
283 Name="hashkit"
284 >
285 <File
286 RelativePath="..\libhashkit\algorithm.c"
287 >
288 </File>
289 <File
290 RelativePath="..\libhashkit\behavior.c"
291 >
292 </File>
293 <File
294 RelativePath="..\libhashkit\crc32.c"
295 >
296 </File>
297 <File
298 RelativePath="..\libhashkit\digest.c"
299 >
300 </File>
301 <File
302 RelativePath="..\libhashkit\fnv.c"
303 >
304 </File>
305 <File
306 RelativePath="..\libhashkit\function.c"
307 >
308 </File>
309 <File
310 RelativePath="..\libhashkit\hashkit.c"
311 >
312 </File>
313 <File
314 RelativePath="..\libhashkit\hsieh.c"
315 >
316 </File>
317 <File
318 RelativePath="..\libhashkit\jenkins.c"
319 >
320 </File>
321 <File
322 RelativePath="..\libhashkit\ketama.c"
323 >
324 </File>
325 <File
326 RelativePath="..\libhashkit\md5.c"
327 >
328 </File>
329 <File
330 RelativePath="..\libhashkit\murmur.c"
331 >
332 </File>
333 <File
334 RelativePath="..\libhashkit\one_at_a_time.c"
335 >
336 </File>
337 <File
338 RelativePath="..\libhashkit\strerror.c"
339 >
340 </File>
341 </Filter>
342 <Filter
343 Name="poll"
344 >
345 <File
346 RelativePath="..\poll\poll.c"
347 >
348 </File>
349 </Filter>
350 <Filter
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches

to all changes: