Put stuff into the send buffer. * * It is guaranteed that this function will never have as a side effect * the link to be invalidated, so it is safe to call this function * from event handlers that will do stuff with the same link later. */
| 2395 | * the link to be invalidated, so it is safe to call this function |
| 2396 | * from event handlers that will do stuff with the same link later. */ |
| 2397 | void clusterSendMessage(clusterLink *link, unsigned char *msg, size_t msglen) { |
| 2398 | if (sdslen(link->sndbuf) == 0 && msglen != 0) |
| 2399 | connSetWriteHandlerWithBarrier(link->conn, clusterWriteHandler, 1); |
| 2400 | |
| 2401 | link->sndbuf = sdscatlen(link->sndbuf, msg, msglen); |
| 2402 | |
| 2403 | /* Populate sent messages stats. */ |
| 2404 | clusterMsg *hdr = (clusterMsg*) msg; |
| 2405 | uint16_t type = ntohs(hdr->type); |
| 2406 | if (type < CLUSTERMSG_TYPE_COUNT) |
| 2407 | server.cluster->stats_bus_messages_sent[type]++; |
| 2408 | } |
| 2409 | |
| 2410 | /* Send a message to all the nodes that are part of the cluster having |
| 2411 | * a connected link. |
no test coverage detected