projects
/
lttng-tools.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Update and fix UST register and session creation
[lttng-tools.git]
/
ltt-sessiond
/
ust-comm.c
diff --git
a/ltt-sessiond/ust-comm.c
b/ltt-sessiond/ust-comm.c
index accd4276d27c48156bfebb3e0a92602f75b6c60f..31c40070e92758b94779ef6b58e27f7b5ce39a23 100644
(file)
--- a/
ltt-sessiond/ust-comm.c
+++ b/
ltt-sessiond/ust-comm.c
@@
-16,6
+16,8
@@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
+#include <stdlib.h>
+
#include <lttngerr.h>
#include "ust-comm.h"
#include <lttngerr.h>
#include "ust-comm.h"
@@
-24,12
+26,18
@@
* Send msg containing a command to an UST application via sock and wait for
* the reply.
*
* Send msg containing a command to an UST application via sock and wait for
* the reply.
*
- * Return
-1 on error or if reply fails else return 0
.
+ * Return
the replied structure or NULL
.
*/
*/
-int ustcomm_send_command(int sock, struct lttcomm_ust_msg *msg)
+struct lttcomm_ust_reply *ustcomm_send_command(int sock,
+ struct lttcomm_ust_msg *msg)
{
ssize_t len;
{
ssize_t len;
- struct lttcomm_ust_reply reply;
+ struct lttcomm_ust_reply *reply;
+
+ /* Extra safety */
+ if (msg == NULL || sock < 0) {
+ goto error;
+ }
DBG("Sending UST command %d to sock %d", msg->cmd, sock);
DBG("Sending UST command %d to sock %d", msg->cmd, sock);
@@
-39,20
+47,22
@@
int ustcomm_send_command(int sock, struct lttcomm_ust_msg *msg)
goto error;
}
goto error;
}
- DBG("Receiving UST reply on sock %d", sock);
-
- /* Get UST reply */
- len = lttcomm_recv_unix_sock(sock, &reply, sizeof(reply));
- if (len < 0) {
+ reply = malloc(sizeof(struct lttcomm_ust_reply));
+ if (reply == NULL) {
+ perror("malloc ust reply");
goto error;
}
goto error;
}
- if (reply.ret_code != LTTCOMM_OK) {
+ DBG("Receiving UST reply on sock %d", sock);
+
+ /* Get UST reply */
+ len = lttcomm_recv_unix_sock(sock, reply, sizeof(*reply));
+ if (len < 0 || len < sizeof(*reply)) {
goto error;
}
goto error;
}
- return
0
;
+ return
reply
;
error:
error:
- return
-1
;
+ return
NULL
;
}
}
This page took
0.025756 seconds
and
4
git commands to generate.