~yshurik/libmemcached/libmemcached-win

« back to all changes in this revision

Viewing changes to libmemcached/stats.cc

  • Committer: Continuous Integration
  • Date: 2013-04-03 13:16:24 UTC
  • mfrom: (1100.1.1 libmemcached-1.2)
  • Revision ID: ci@tangent.org-20130403131624-j59dhv5z5l0lsdld
Merge lp:~tangent-org/libmemcached/1.2-build/ Build: jenkins-Libmemcached-250

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 * 
3
3
 *  Libmemcached library
4
4
 *
5
 
 *  Copyright (C) 2011 Data Differential, http://datadifferential.com/
 
5
 *  Copyright (C) 2011-2013 Data Differential, http://datadifferential.com/
6
6
 *
7
7
 *  Redistribution and use in source and binary forms, with or without
8
8
 *  modification, are permitted provided that the following conditions are
91
91
  }
92
92
  else if (strcmp("pid", key) == 0)
93
93
  {
 
94
    errno= 0;
94
95
    int64_t temp= strtoll(value, (char **)NULL, 10);
 
96
    if (errno != 0)
 
97
    {
 
98
      return MEMCACHED_FAILURE;
 
99
    }
95
100
 
96
101
    if (temp <= INT32_MAX and ( sizeof(pid_t) == sizeof(int32_t) ))
97
102
    {
109
114
  }
110
115
  else if (not strcmp("uptime", key))
111
116
  {
 
117
    errno= 0;
112
118
    memc_stat->uptime= strtoul(value, (char **)NULL, 10);
 
119
    if (errno != 0)
 
120
    {
 
121
      return MEMCACHED_FAILURE;
 
122
    }
113
123
  }
114
124
  else if (not strcmp("time", key))
115
125
  {
 
126
    errno= 0;
116
127
    memc_stat->time= strtoul(value, (char **)NULL, 10);
 
128
    if (errno != 0)
 
129
    {
 
130
      return MEMCACHED_FAILURE;
 
131
    }
117
132
  }
118
133
  else if (not strcmp("version", key))
119
134
  {
122
137
  }
123
138
  else if (not strcmp("pointer_size", key))
124
139
  {
 
140
    errno= 0;
125
141
    memc_stat->pointer_size= strtoul(value, (char **)NULL, 10);
 
142
    if (errno != 0)
 
143
    {
 
144
      return MEMCACHED_FAILURE;
 
145
    }
126
146
  }
127
147
  else if (not strcmp("rusage_user", key))
128
148
  {
130
150
    for (walk_ptr= (char*)value; (!ispunct(*walk_ptr)); walk_ptr++) {};
131
151
    *walk_ptr= 0;
132
152
    walk_ptr++;
 
153
 
 
154
    errno= 0;
133
155
    memc_stat->rusage_user_seconds= strtoul(value, (char **)NULL, 10);
 
156
    if (errno != 0)
 
157
    {
 
158
      return MEMCACHED_FAILURE;
 
159
    }
 
160
 
 
161
    errno= 0;
134
162
    memc_stat->rusage_user_microseconds= strtoul(walk_ptr, (char **)NULL, 10);
 
163
    if (errno != 0)
 
164
    {
 
165
      return MEMCACHED_FAILURE;
 
166
    }
135
167
  }
136
168
  else if (not strcmp("rusage_system", key))
137
169
  {
139
171
    for (walk_ptr= (char*)value; (!ispunct(*walk_ptr)); walk_ptr++) {};
140
172
    *walk_ptr= 0;
141
173
    walk_ptr++;
 
174
 
 
175
    errno= 0;
142
176
    memc_stat->rusage_system_seconds= strtoul(value, (char **)NULL, 10);
 
177
    if (errno != 0)
 
178
    {
 
179
      return MEMCACHED_FAILURE;
 
180
    }
 
181
 
 
182
    errno= 0;
143
183
    memc_stat->rusage_system_microseconds= strtoul(walk_ptr, (char **)NULL, 10);
 
184
    if (errno != 0)
 
185
    {
 
186
      return MEMCACHED_FAILURE;
 
187
    }
144
188
  }
145
189
  else if (not strcmp("curr_items", key))
146
190
  {
 
191
    errno= 0;
147
192
    memc_stat->curr_items= strtoul(value, (char **)NULL, 10);
 
193
    if (errno != 0)
 
194
    {
 
195
      return MEMCACHED_FAILURE;
 
196
    }
148
197
  }
149
198
  else if (not strcmp("total_items", key))
150
199
  {
 
200
    errno= 0;
151
201
    memc_stat->total_items= strtoul(value, (char **)NULL, 10);
 
202
    if (errno != 0)
 
203
    {
 
204
      return MEMCACHED_FAILURE;
 
205
    }
152
206
  }
153
207
  else if (not strcmp("bytes_read", key))
154
208
  {
 
209
    errno= 0;
155
210
    memc_stat->bytes_read= strtoull(value, (char **)NULL, 10);
 
211
    if (errno != 0)
 
212
    {
 
213
      return MEMCACHED_FAILURE;
 
214
    }
156
215
  }
157
216
  else if (not strcmp("bytes_written", key))
158
217
  {
 
218
    errno= 0;
159
219
    memc_stat->bytes_written= strtoull(value, (char **)NULL, 10);
 
220
    if (errno != 0)
 
221
    {
 
222
      return MEMCACHED_FAILURE;
 
223
    }
160
224
  }
161
225
  else if (not strcmp("bytes", key))
162
226
  {
 
227
    errno= 0;
163
228
    memc_stat->bytes= strtoull(value, (char **)NULL, 10);
 
229
    if (errno != 0)
 
230
    {
 
231
      return MEMCACHED_FAILURE;
 
232
    }
164
233
  }
165
234
  else if (not strcmp("curr_connections", key))
166
235
  {
 
236
    errno= 0;
167
237
    memc_stat->curr_connections= strtoull(value, (char **)NULL, 10);
 
238
    if (errno != 0)
 
239
    {
 
240
      return MEMCACHED_FAILURE;
 
241
    }
168
242
  }
169
243
  else if (not strcmp("total_connections", key))
170
244
  {
 
245
    errno= 0;
171
246
    memc_stat->total_connections= strtoull(value, (char **)NULL, 10);
 
247
    if (errno != 0)
 
248
    {
 
249
      return MEMCACHED_FAILURE;
 
250
    }
172
251
  }
173
252
  else if (not strcmp("connection_structures", key))
174
253
  {
 
254
    errno= 0;
175
255
    memc_stat->connection_structures= strtoul(value, (char **)NULL, 10);
 
256
    if (errno != 0)
 
257
    {
 
258
      return MEMCACHED_FAILURE;
 
259
    }
176
260
  }
177
261
  else if (not strcmp("cmd_get", key))
178
262
  {
 
263
    errno= 0;
179
264
    memc_stat->cmd_get= strtoull(value, (char **)NULL, 10);
 
265
    if (errno != 0)
 
266
    {
 
267
      return MEMCACHED_FAILURE;
 
268
    }
180
269
  }
181
270
  else if (not strcmp("cmd_set", key))
182
271
  {
 
272
    errno= 0;
183
273
    memc_stat->cmd_set= strtoull(value, (char **)NULL, 10);
 
274
    if (errno != 0)
 
275
    {
 
276
      return MEMCACHED_FAILURE;
 
277
    }
184
278
  }
185
279
  else if (not strcmp("get_hits", key))
186
280
  {
 
281
    errno= 0;
187
282
    memc_stat->get_hits= strtoull(value, (char **)NULL, 10);
 
283
    if (errno != 0)
 
284
    {
 
285
      return MEMCACHED_FAILURE;
 
286
    }
188
287
  }
189
288
  else if (not strcmp("get_misses", key))
190
289
  {
 
290
    errno= 0;
191
291
    memc_stat->get_misses= strtoull(value, (char **)NULL, 10);
 
292
    if (errno != 0)
 
293
    {
 
294
      return MEMCACHED_FAILURE;
 
295
    }
192
296
  }
193
297
  else if (not strcmp("evictions", key))
194
298
  {
 
299
    errno= 0;
195
300
    memc_stat->evictions= strtoull(value, (char **)NULL, 10);
 
301
    if (errno != 0)
 
302
    {
 
303
      return MEMCACHED_FAILURE;
 
304
    }
196
305
  }
197
306
  else if (not strcmp("limit_maxbytes", key))
198
307
  {
 
308
    errno= 0;
199
309
    memc_stat->limit_maxbytes= strtoull(value, (char **)NULL, 10);
 
310
    if (errno != 0)
 
311
    {
 
312
      return MEMCACHED_FAILURE;
 
313
    }
200
314
  }
201
315
  else if (not strcmp("threads", key))
202
316
  {
 
317
    errno= 0;
203
318
    memc_stat->threads= strtoul(value, (char **)NULL, 10);
 
319
    if (errno != 0)
 
320
    {
 
321
      return MEMCACHED_FAILURE;
 
322
    }
204
323
  }
205
 
  else if (not (strcmp("delete_misses", key) == 0 or /* New stats in the 1.3 beta */
206
 
                strcmp("delete_hits", key) == 0 or /* Just swallow them for now.. */
207
 
                strcmp("incr_misses", key) == 0 or
208
 
                strcmp("incr_hits", key) == 0 or
209
 
                strcmp("decr_misses", key) == 0 or
210
 
                strcmp("decr_hits", key) == 0 or
211
 
                strcmp("cas_misses", key) == 0 or
212
 
                strcmp("cas_hits", key) == 0 or
213
 
                strcmp("cas_badval", key) == 0 or
214
 
                strcmp("cmd_flush", key) == 0 or
215
 
                strcmp("accepting_conns", key) == 0 or
216
 
                strcmp("listen_disabled_num", key) == 0 or
217
 
                strcmp("conn_yields", key) == 0 or
218
 
                strcmp("auth_cmds", key) == 0 or
219
 
                strcmp("auth_errors", key) == 0 or
220
 
                strcmp("reclaimed", key) == 0))
 
324
  else if ((strcmp("delete_misses", key) == 0 or /* New stats in the 1.3 beta */
 
325
            strcmp("delete_hits", key) == 0 or /* Just swallow them for now.. */
 
326
            strcmp("incr_misses", key) == 0 or
 
327
            strcmp("incr_hits", key) == 0 or
 
328
            strcmp("decr_misses", key) == 0 or
 
329
            strcmp("decr_hits", key) == 0 or
 
330
            strcmp("cas_misses", key) == 0 or
 
331
            strcmp("cas_hits", key) == 0 or
 
332
            strcmp("cas_badval", key) == 0 or
 
333
            strcmp("cmd_flush", key) == 0 or
 
334
            strcmp("accepting_conns", key) == 0 or
 
335
            strcmp("listen_disabled_num", key) == 0 or
 
336
            strcmp("conn_yields", key) == 0 or
 
337
            strcmp("auth_cmds", key) == 0 or
 
338
            strcmp("auth_errors", key) == 0 or
 
339
            strcmp("reclaimed", key) == 0) == 0)
221
340
  {
222
341
    WATCHPOINT_STRING(key);
223
342
    /* return MEMCACHED_UNKNOWN_STAT_KEY; */
358
477
static memcached_return_t binary_stats_fetch(memcached_stat_st *memc_stat,
359
478
                                             const char *args,
360
479
                                             const size_t args_length,
361
 
                                             org::libmemcached::Instance* instance,
 
480
                                             memcached_instance_st* instance,
362
481
                                             struct local_context *check)
363
482
{
364
483
  char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE];
448
567
static memcached_return_t ascii_stats_fetch(memcached_stat_st *memc_stat,
449
568
                                            const char *args,
450
569
                                            const size_t args_length,
451
 
                                            org::libmemcached::Instance* instance,
 
570
                                            memcached_instance_st* instance,
452
571
                                            struct local_context *check)
453
572
{
454
573
  libmemcached_io_vector_st vector[]=
565
684
    stat_instance->pid= -1;
566
685
    stat_instance->root= self;
567
686
 
568
 
    org::libmemcached::Instance* instance= memcached_instance_fetch(self, x);
 
687
    memcached_instance_st* instance= memcached_instance_fetch(self, x);
569
688
 
570
689
    memcached_return_t temp_return;
571
690
    if (memcached_is_binary(self))
632
751
 
633
752
    if (memcached_success(rc))
634
753
    {
635
 
      org::libmemcached::Instance* instance= memcached_instance_fetch(memc_ptr, 0);
 
754
      memcached_instance_st* instance= memcached_instance_fetch(memc_ptr, 0);
636
755
      if (memc.flags.binary_protocol)
637
756
      {
638
757
        rc= binary_stats_fetch(memc_stat, args, args_length, instance, NULL);
694
813
}
695
814
 
696
815
static memcached_return_t call_stat_fn(memcached_st *memc,
697
 
                                       org::libmemcached::Instance* instance,
 
816
                                       memcached_instance_st* instance,
698
817
                                       void *context)
699
818
{
700
819
  if (memc)