wangzhengquan
2021-01-22 91ea20d03ebb5a8d20150d3ecc28a13c51ce93f1
src/socket/shm_socket.cpp
@@ -373,9 +373,9 @@
  memcpy(dest.buf, buf, size);
 
  if(flags & SHM_MSG_NOWAIT != 0) {
  if( (flags & BUS_NOWAIT_FLAG) == BUS_NOWAIT_FLAG) {
    rv = remoteQueue->push_nowait(dest);
  } else if(timeout != NULL) {
  } else if((flags & BUS_TIMEOUT_FLAG) == BUS_TIMEOUT_FLAG && timeout != NULL) {
     rv = remoteQueue->push_timeout(dest, timeout);
  } else {
     rv = remoteQueue->push(dest);
@@ -383,10 +383,8 @@
  if (rv == 0) {
    // printf("shm_sendto push after\n");
    delete remoteQueue;
    return 0;
  } else {
    delete remoteQueue;
    mm_free(dest.buf);
    if(rv > EBUS_BASE) {
      // bus_errno = EBUS_TIMEOUT;
@@ -395,8 +393,6 @@
      logger->error(rv, "sendto key %d failed", key);
    }
    return rv;
  }
}
@@ -435,9 +431,9 @@
  shm_msg_t src;
 
   if(flags & SHM_MSG_NOWAIT != 0) {
   if((flags & BUS_NOWAIT_FLAG) == BUS_NOWAIT_FLAG) {
    rv = socket->queue->pop_nowait(src);
  } else if(timeout != NULL) {
  } else if((flags & BUS_TIMEOUT_FLAG) == BUS_TIMEOUT_FLAG && timeout != NULL) {
    rv = socket->queue->pop_timeout(src, timeout);
// printf("0 shm_recvfrom====%d\n", rv);
  } else {
@@ -651,7 +647,7 @@
    switch (src.type) {
    case SHM_SOCKET_OPEN:
      socket->acceptQueue->push_timeout(src, &timeout);
      socket->acceptQueue->push(src, &timeout, BUS_TIMEOUT_FLAG);
      break;
    case SHM_SOCKET_CLOSE:
      _server_close_conn_to_client(socket, src.key);
@@ -662,7 +658,7 @@
      if (iter != socket->clientSocketMap->end()) {
        client_socket = iter->second;
        // print_msg("_server_run_msg_rev push before", src);
        client_socket->messageQueue->push_timeout(src, &timeout);
        client_socket->messageQueue->push(src, &timeout, BUS_TIMEOUT_FLAG);
        // print_msg("_server_run_msg_rev push after", src);
      }
@@ -697,7 +693,7 @@
      _client_close_conn_to_server(socket);
      break;
    case SHM_COMMON_MSG:
      socket->messageQueue->push_timeout(src, &timeout);
      socket->messageQueue->push(src, &timeout, BUS_TIMEOUT_FLAG);
      break;
    default:
       logger->error( "shm_socket._client_run_msg_rev: undefined message type.");
@@ -725,10 +721,7 @@
    socket->queue = NULL;
  }
  if (socket->remoteQueue != NULL) {
    delete socket->remoteQueue;
    socket->remoteQueue = NULL;
  }
  if (socket->messageQueue != NULL) {
    delete socket->messageQueue;
@@ -747,7 +740,6 @@
      client_socket = iter->second;
      client_socket->remoteQueue->push_timeout(close_msg, &timeout);
      delete client_socket->remoteQueue;
      client_socket->remoteQueue = NULL;
      delete client_socket->messageQueue;