-
-
Save jarda-manana/053be1411c24ae4cbdcf to your computer and use it in GitHub Desktop.
ilustrating shm problem in aerospike-client-c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdbool.h> | |
#include <stddef.h> | |
#include <stdint.h> | |
#include <stdlib.h> | |
#include <unistd.h> | |
#include <stdio.h> | |
#include <time.h> | |
#include <aerospike/aerospike.h> | |
#include <aerospike/aerospike_info.h> | |
int | |
main(int argc, char* argv[]) | |
{ | |
aerospike as; | |
as_config cfg; | |
as_config_init(&cfg); | |
cfg.policies.timeout = 3000; | |
cfg.policies.retry = 3; | |
cfg.use_shm = true; | |
cfg.shm_takeover_threshold_sec=1; | |
// set hosts from argv | |
for (int i = 1; i < argc; ++i) | |
as_config_add_host(&cfg, argv[i], 3000); | |
aerospike_init(&as, &cfg); | |
as_error err; | |
if (aerospike_connect(&as, &err) != AEROSPIKE_OK) { | |
printf("aerospike_connect() returned %d - %s\n", err.code, err.message); | |
aerospike_destroy(&as); | |
exit(-1); | |
} | |
for(int64_t i = 0; i < 5; ++i) { | |
char * res = NULL; | |
if (aerospike_info_any(&as, &err, NULL, "service", &res) != AEROSPIKE_OK) { | |
printf("aerospike_info_any returned %d - %s\n", err.code, err.message); | |
} else { | |
printf("aerospike_info_any response ok: %s\n", res); | |
free(res); | |
res = NULL; | |
} | |
sleep(1); | |
} | |
aerospike_close(&as, &err); | |
aerospike_destroy(&as); | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdbool.h> | |
#include <stddef.h> | |
#include <stdint.h> | |
#include <stdlib.h> | |
#include <unistd.h> | |
#include <stdio.h> | |
#include <aerospike/aerospike.h> | |
#include <aerospike/aerospike_info.h> | |
int | |
main(int argc, char* argv[]) | |
{ | |
aerospike as; | |
as_config cfg; | |
as_config_init(&cfg); | |
cfg.policies.timeout = 3000; | |
cfg.policies.retry = 3; | |
cfg.use_shm = true; | |
cfg.shm_takeover_threshold_sec=1; | |
// set hosts from argv | |
for (int i = 1; i < argc; ++i) | |
as_config_add_host(&cfg, argv[i], 3000); | |
aerospike_init(&as, &cfg); | |
as_error err; | |
if (aerospike_connect(&as, &err) != AEROSPIKE_OK) { | |
printf("aerospike_connect() returned %d - %s\n", err.code, err.message); | |
aerospike_destroy(&as); | |
exit(-1); | |
} | |
//SIGSEGV | |
int *i = 0; | |
++*i; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment