wangzhengquan
2021-02-03 f1ae0552e2d50ce6f87a0bad2f31b8e2ec617bb7
src/socket/shm_socket.cpp
@@ -148,7 +148,10 @@
  hashtable_t *hashtable = mm_get_hashtable();
  if( sockt->queue != NULL)
    goto LABEL_PUSH;
 
  {
  if ((rv = pthread_mutex_lock(&(sockt->mutex))) != 0)
    err_exit(rv, "shm_sendto : pthread_mutex_lock");
@@ -166,9 +169,10 @@
  if ((rv = pthread_mutex_unlock(&(sockt->mutex))) != 0)
    err_exit(rv, "shm_sendto : pthread_mutex_unlock");
  
  // There is some case where a sockt need to send to himeself, for example when bus server need to stop, he need to send himself
  // a top message.
  }
  
 LABEL_PUSH:
  if (key == sockt->key) {
    logger->error( "can not send to your self!");
    return EBUS_SENDTO_SELF;
@@ -210,10 +214,14 @@
  
  hashtable_t *hashtable = mm_get_hashtable();
  if( sockt->queue != NULL)
    goto LABEL_POP;
  {
  if ((rv = pthread_mutex_lock(&(sockt->mutex))) != 0)
    err_exit(rv, "shm_recvfrom : pthread_mutex_lock");
 
  if (sockt->queue == NULL) {
    if (sockt->key == 0) {
      sockt->key = hashtable_alloc_key(hashtable);
    }  
@@ -222,11 +230,15 @@
      logger->error("%s. key = %d", bus_strerror(EBUS_KEY_INUSED), sockt->key);
      return EBUS_KEY_INUSED;
    }
  }
  
  if ((rv = pthread_mutex_unlock(&(sockt->mutex))) != 0)
    err_exit(rv, "shm_recvfrom : pthread_mutex_unlock");
  }
LABEL_POP:
  shm_packet_t src;
 
  rv = sockt->queue->pop(src, timeout, flag);