-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathshmclient.c
More file actions
91 lines (75 loc) · 1.44 KB
/
shmclient.c
File metadata and controls
91 lines (75 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <time.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <err.h>
#include "shm_config.h"
#include "shmqueue.h"
void usage(void);
struct shmqueue *shmqueue;
void
usage()
{
printf("usage: shmclient -dt\n");
}
int
main(int argc, char *argv[])
{
struct keyvalue kv;
int ch, i, rc, nloop;
int opt_d = 0, opt_t = 0;
while ((ch = getopt(argc, argv, "dt")) != -1) {
switch (ch) {
case 'd':
opt_d = 1;
break;
case 't':
opt_t = 1;
break;
default:
usage();
return 1;
}
}
argc -= optind;
argv += optind;
shmqueue = shmqueue_new(MEMID, 0, 1, 1);
for (nloop = i = 0; i >= 0; i++, nloop++) {
#if 1
char key[1024];
char data[1024];
sprintf(key, "%d", i);
sprintf(data, "data of %d", i);
rc = shmqueue_keyvalue_store(shmqueue, (uint8_t *)key, (uint8_t *)data, strlen(data));
if (rc != 0) {
if ((nloop & 0xffff) == 0)
printf("¼ºÇÔ¤·¤¿(%d)\n", i);
i--;
continue;
}
if ((i & 0xff) == 0)
printf("À®¸ù¤·¤¿(%d)\n", i);
fflush(stdout);
#endif
}
(void)&rc;
(void)&kv;
#if 0
for (i = 0; i < 10000; i++) {
rc = shmqueue_getoldest(shmqueue, &kv);
printf("rc = %d\n", rc);
fflush(stdout);
if (rc == 0) {
fprintf(stderr, "EXPIRE: key=<%s>, storage_size=%u, storage=<%s>\n",
KEYVALUE_KEY(&kv),
kv.kv_storagesize,
KEYVALUE_STORAGE(&kv));
}
}
#endif
return 0;
}