| | |
| | | .PHONY: clean |
| | | clean: |
| | | rm -f $(OBJS) $(MYLIBS) $(DEPENDENCES) $(TEMPFILES) |
| | | rm -rf $(DEST)/* |
| | | |
| | | |
| | | -include $(DEPENDENCES) |
| | |
| | | |
| | | static size_t hashcode(int key); |
| | | |
| | | static struct timespec TIMEOUT = {1, 0}; |
| | | |
| | | void hashtable_init(hashtable_t *hashtable ) |
| | | { |
| | | |
| | |
| | | /*printf("hashfun = %ld\n", code);*/ |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | void *hashtable_get(hashtable_t *hashtable, int key) { |
| | | struct timespec timeout = {1, 0}; |
| | | if (SemUtil::dec_timeout(hashtable->mutex, &timeout) != 0) { |
| | | |
| | | if (SemUtil::dec_timeout(hashtable->mutex, &TIMEOUT) != 0) { |
| | | SemUtil::inc(hashtable->mutex); |
| | | SemUtil::dec(hashtable->mutex); |
| | | } |
| | |
| | | int hashtable_alloc_key(hashtable_t *hashtable) { |
| | | int key = START_KEY; |
| | | |
| | | struct timespec timeout = {1, 0}; |
| | | if (SemUtil::dec_timeout(hashtable->wlock, &timeout) != 0) { |
| | | if (SemUtil::dec_timeout(hashtable->wlock, &TIMEOUT) != 0) { |
| | | SemUtil::inc(hashtable->wlock); |
| | | SemUtil::dec(hashtable->wlock); |
| | | } |
| | |
| | | client |
| | | ;; |
| | | "mclient") |
| | | close |
| | | server |
| | | |
| | | mclient |
| | | ;; |
| | | "close") |
| | |
| | | |
| | | net_node_t *node_arr; |
| | | int node_arr_size = parse_node_list(targ->sendlist, &node_arr); |
| | | |
| | | |
| | | void * client = net_mod_socket_open(); |
| | | |
| | |
| | | net_node_t *node_arr = (net_node_t *) calloc(entry_arr_len, sizeof(net_node_t)); |
| | | for(i = 0; i < entry_arr_len; i++) { |
| | | property_arr_len = str_split(entry_arr[i], ":", &property_arr); |
| | | printf("%s, %s, %s\n", property_arr[0], property_arr[1], property_arr[2]); |
| | | node_arr[i] = {trim(property_arr[0], 0), atoi(property_arr[1]), atoi(property_arr[2])}; |
| | | free(entry_arr[i]); |
| | | free(property_arr[1]); |
| | |
| | | } |
| | | |
| | | void print_node_list(net_node_t *node_arr, int len) { |
| | | printf("============node list begin==========\n"); |
| | | for(int i = 0; i < len; i++) { |
| | | printf("%s,%d,%d,\n", node_arr[i].host, node_arr[i].port, node_arr[i].key); |
| | | } |
| | | printf("============node list end==========\n"); |
| | | } |