~john-koepi/ubuntu/trusty/memcached/default

« back to all changes in this revision

Viewing changes to memcached.h

  • Committer: Bazaar Package Importer
  • Author(s): Scott Kitterman
  • Date: 2011-10-05 13:27:39 UTC
  • mfrom: (1.1.8 upstream) (3.3.4 sid)
  • Revision ID: james.westby@ubuntu.com-20111005132739-ntsnlj16fcze221i
Tags: 1.4.7-0.1ubuntu1
* Merge from debian unstable.  Remaining changes:
  - Run as 'memcache' user instead of nobody (LP #599461)
  - Depend on adduser for preinst/postrm
  - Create user in postinst

Show diffs side-by-side

added added

removed removed

Lines of Context:
77
77
#define TAIL_REPAIR_TIME (3 * 3600)
78
78
 
79
79
/* warning: don't use these macros with a function, as it evals its arg twice */
80
 
#define ITEM_get_cas(i) ((uint64_t)(((i)->it_flags & ITEM_CAS) ? \
81
 
                                    *(uint64_t*)&((i)->end[0]) : 0x0))
82
 
#define ITEM_set_cas(i,v) { if ((i)->it_flags & ITEM_CAS) { \
83
 
                          *(uint64_t*)&((i)->end[0]) = v; } }
84
 
 
85
 
#define ITEM_key(item) (((char*)&((item)->end[0])) \
86
 
         + (((item)->it_flags & ITEM_CAS) ? sizeof(uint64_t) : 0))
87
 
 
88
 
#define ITEM_suffix(item) ((char*) &((item)->end[0]) + (item)->nkey + 1 \
89
 
         + (((item)->it_flags & ITEM_CAS) ? sizeof(uint64_t) : 0))
90
 
 
91
 
#define ITEM_data(item) ((char*) &((item)->end[0]) + (item)->nkey + 1 \
 
80
#define ITEM_get_cas(i) (((i)->it_flags & ITEM_CAS) ? \
 
81
        (i)->data->cas : (uint64_t)0)
 
82
 
 
83
#define ITEM_set_cas(i,v) { \
 
84
    if ((i)->it_flags & ITEM_CAS) { \
 
85
        (i)->data->cas = v; \
 
86
    } \
 
87
}
 
88
 
 
89
#define ITEM_key(item) (((char*)&((item)->data)) \
 
90
         + (((item)->it_flags & ITEM_CAS) ? sizeof(uint64_t) : 0))
 
91
 
 
92
#define ITEM_suffix(item) ((char*) &((item)->data) + (item)->nkey + 1 \
 
93
         + (((item)->it_flags & ITEM_CAS) ? sizeof(uint64_t) : 0))
 
94
 
 
95
#define ITEM_data(item) ((char*) &((item)->data) + (item)->nkey + 1 \
92
96
         + (item)->nsuffix \
93
97
         + (((item)->it_flags & ITEM_CAS) ? sizeof(uint64_t) : 0))
94
98
 
187
191
};
188
192
 
189
193
enum delta_result_type {
190
 
    OK, NON_NUMERIC, EOM
 
194
    OK, NON_NUMERIC, EOM, DELTA_ITEM_NOT_FOUND, DELTA_ITEM_CAS_MISMATCH
191
195
};
192
196
 
193
197
/** Time relative to server start. Smaller than time_t on 64-bit systems. */
266
270
    double factor;          /* chunk size growth factor */
267
271
    int chunk_size;
268
272
    int num_threads;        /* number of worker (without dispatcher) libevent threads to run */
 
273
    int num_threads_per_udp; /* number of worker threads serving each udp socket */
269
274
    char prefix_delimiter;  /* character that marks a key prefix (for stats) */
270
275
    int detail_enabled;     /* nonzero if we're collecting detailed stats */
271
276
    int reqs_per_event;     /* Maximum number of io to process on each
302
307
    uint8_t         it_flags;   /* ITEM_* above */
303
308
    uint8_t         slabs_clsid;/* which slab class we're in */
304
309
    uint8_t         nkey;       /* key length, w/terminating null and padding */
305
 
    void * end[];
 
310
    /* this odd type prevents type-punning issues when we do
 
311
     * the little shuffle to save space when not using CAS. */
 
312
    union {
 
313
        uint64_t cas;
 
314
        char end;
 
315
    } data[];
306
316
    /* if it_flags & ITEM_CAS we have 8 bytes CAS */
307
317
    /* then null-terminated key */
308
318
    /* then " flags length\r\n" (no terminating null) */
425
435
 * Functions
426
436
 */
427
437
void do_accept_new_conns(const bool do_accept);
428
 
enum delta_result_type do_add_delta(conn *c, item *item, const bool incr,
429
 
                                    const int64_t delta, char *buf);
 
438
enum delta_result_type do_add_delta(conn *c, const char *key,
 
439
                                    const size_t nkey, const bool incr,
 
440
                                    const int64_t delta, char *buf,
 
441
                                    uint64_t *cas);
430
442
enum store_item_type do_store_item(item *item, int comm, conn* c);
431
443
conn *conn_new(const int sfd, const enum conn_states init_state, const int event_flags, const int read_buffer_size, enum network_transport transport, struct event_base *base);
432
444
extern int daemonize(int nochdir, int noclose);
452
464
void dispatch_conn_new(int sfd, enum conn_states init_state, int event_flags, int read_buffer_size, enum network_transport transport);
453
465
 
454
466
/* Lock wrappers for cache functions that are called from main loop. */
455
 
enum delta_result_type add_delta(conn *c, item *item, const int incr,
456
 
                                 const int64_t delta, char *buf);
 
467
enum delta_result_type add_delta(conn *c, const char *key,
 
468
                                 const size_t nkey, const int incr,
 
469
                                 const int64_t delta, char *buf,
 
470
                                 uint64_t *cas);
457
471
void accept_new_conns(const bool do_accept);
458
472
conn *conn_from_freelist(void);
459
473
bool  conn_add_to_freelist(conn *c);