wangzhengquan
2020-11-27 b5fe7f9a3bcc2f20d127f9081c1cf132091f6a57
update
4个文件已修改
20 ■■■■■ 已修改文件
src/Makefile 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/queue/hashtable.c 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
test_net_socket/net_mod_socket.sh 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
test_net_socket/test_net_mod_socket.c 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/Makefile
@@ -84,6 +84,7 @@
.PHONY: clean
clean:
    rm -f $(OBJS) $(MYLIBS) $(DEPENDENCES) $(TEMPFILES)
    rm -rf $(DEST)/*
-include $(DEPENDENCES)
src/queue/hashtable.c
@@ -23,6 +23,8 @@
static size_t hashcode(int key);
static struct timespec TIMEOUT = {1, 0};
void hashtable_init(hashtable_t *hashtable )
{
  
@@ -179,12 +181,9 @@
  /*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);
   }
@@ -317,8 +316,7 @@
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);
  }
test_net_socket/net_mod_socket.sh
@@ -50,8 +50,7 @@
     client
  ;;
  "mclient")
    close
    server
    mclient
  ;;
  "close")
test_net_socket/test_net_mod_socket.c
@@ -155,6 +155,7 @@
  net_node_t *node_arr;
  int node_arr_size = parse_node_list(targ->sendlist, &node_arr);
  void * client = net_mod_socket_open();
    
@@ -460,6 +461,7 @@
  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]);
@@ -472,7 +474,9 @@
}
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");
}