char *buf;
uint64_t buf_size = sizeof(header);
+ if (rsock->sock.fd < 0) {
+ return -ECONNRESET;
+ }
+
if (data) {
buf_size += size;
}
{
int ret;
- DBG3("Relayd waiting for reply of size %ld", size);
+ if (rsock->sock.fd < 0) {
+ return -ECONNRESET;
+ }
+
+ DBG3("Relayd waiting for reply of size %zu", size);
ret = rsock->sock.ops->recvmsg(&rsock->sock, data, size, 0);
if (ret <= 0 || ret != size) {
/* Orderly shutdown. */
DBG("Socket %d has performed an orderly shutdown", rsock->sock.fd);
} else {
- DBG("Receiving reply failed on sock %d for size %lu with ret %d",
+ DBG("Receiving reply failed on sock %d for size %zu with ret %d",
rsock->sock.fd, size, ret);
}
/* Always return -1 here and the caller can use errno. */
/* Code flow error. Safety net. */
assert(rsock);
+ if (!rsock->sock.ops) {
+ /*
+ * Attempting a connect on a non-initialized socket.
+ */
+ return -ECONNRESET;
+ }
+
DBG3("Relayd connect ...");
return rsock->sock.ops->connect(&rsock->sock);
PERROR("relayd_close default close");
}
}
+ rsock->sock.fd = -1;
end:
return ret;
assert(rsock);
assert(hdr);
- DBG3("Relayd sending data header of size %ld", size);
+ if (rsock->sock.fd < 0) {
+ return -ECONNRESET;
+ }
+
+ DBG3("Relayd sending data header of size %zu", size);
/* Again, safety net */
if (size == 0) {
int relayd_end_data_pending(struct lttcomm_relayd_sock *rsock, uint64_t id,
unsigned int *is_data_inflight)
{
- int ret;
+ int ret, recv_ret;
struct lttcomm_relayd_end_data_pending msg;
struct lttcomm_relayd_generic_reply reply;
goto error;
}
- reply.ret_code = be32toh(reply.ret_code);
- if (reply.ret_code < 0) {
- ret = reply.ret_code;
+ recv_ret = be32toh(reply.ret_code);
+ if (recv_ret < 0) {
+ ret = recv_ret;
goto error;
}
- *is_data_inflight = reply.ret_code;
+ *is_data_inflight = recv_ret;
- DBG("Relayd end data pending is data inflight: %d", reply.ret_code);
+ DBG("Relayd end data pending is data inflight: %d", recv_ret);
return 0;