Commit Graph

26 Commits

Author SHA1 Message Date
Antonin Décimo
8033b575f7 ipc: fix aligment issue of data buffer
The pointer `data` is cast to a more strictly aligned pointer type. To
prevent issues, the `data32` buffer is removed and its occurrences are
replaced with an offset from the `data` buffer.
2020-07-30 22:02:42 -04:00
Antonin Décimo
1d6d26cdec ipc-client: remove useless free for failed malloc 2019-08-12 09:42:11 +09:00
Brian Ashworth
18476b0ec1 common/ipc-client: remove ipc recv timeout log
This just removes the ipc recv timeout log statement in
`ipc_recv_set_timeout`. The `tv_sec` field of `struct timeval` has
varying types and/or sizes depending on the platform and architecture.
On some of these, the current format string will cause compilation
errors. Additionally, the log statement is not extremely useful and the
function is currently only used by swaymsg, which has a hardcoded log
level that will prevent it from even being shown, so there is no point
in even keeping it.
2019-05-27 08:02:10 +03:00
Brian Ashworth
d7d29fe546 swaymsg: add timeout and type checks
This adds a 3 second timeout to the initial reply in swaymsg. This
prevents swaymsg from hanging when `swaymsg -t get_{inputs,seats}` is
used in i3. The timeout is removed when waiting for a subscribed event
or monitoring for subscribed events.

This also adds type checks to commands where i3 does not reply with all
of the properties that sway does (such as `modes` in `get_outputs`).

This is mostly just a behavioral adjustment since swaymsg should run on
i3. When running under i3, some command reply's (such as the one for
`get_outputs) may have more useful information in the raw json than the
pretty printed version.
2019-04-17 09:07:08 +03:00
M Stoeckl
1211a81aad Replace wlr_log with sway_log
This commit mostly duplicates the wlr_log functions, although
with a sway_* prefix. (This is very similar to PR #2009.)
However, the logging function no longer needs to be replaceable,
so sway_log_init's second argument is used to set the exit
callback for sway_abort.

wlr_log_init is still invoked in sway/main.c

This commit makes it easier to remove the wlroots dependency for
the helper programs swaymsg, swaybg, swaybar, and swaynag.
2019-01-21 12:59:42 +01:00
M Stoeckl
62260ab56e Fix backup methods in get_socketpath for IPC client
Previously, the success of `getline` was tested by checking if the
buffer it allocates is nonempty and has a nonzero first byte. As
 `getline` does not explicitly zero out its memory buffer, this may
fail (e.g., with AddressSanitizer). Instead, we check that at least one
character was returned on standard output.

Also, trailing newlines (if present) are now removed.
2019-01-19 18:45:25 +01:00
Connor E
de6f5b3453 Use static arrays where possible. 2019-01-16 13:02:26 +01:00
Connor E
aa9d7d8ca1 Remove usage of VLAs. 2019-01-16 13:02:26 +01:00
Ian Fan
a82b8a3c14 Remove readline.c
All occurrences of read_line have been replaced by getline.
peek_line has been absorbed into detect_brace.
2019-01-01 09:01:25 +00:00
taiyu
d625d68d4a
prevent ub caused by misaligned stores/loads 2018-09-02 17:07:12 -07:00
Ian Fan
baf4604629 ipc-client: fix memory leaks in get_socketpath 2018-08-06 17:30:24 +01:00
emersion
63b4bf5000
Update for swaywm/wlroots#1126 2018-07-09 22:54:30 +01:00
Dominique Martinet
25af959fe9 Fix gcc string truncation warnings 2018-04-13 22:47:27 +09:00
Drew DeVault
382e8af418 Allow sway IPC clients to fall back to i3 socket 2018-03-29 22:11:08 -04:00
Dominique Martinet
67985e9031 sway: change all sway_log to wlr_log 2018-01-05 23:39:46 +01:00
Drew DeVault
9aed9d9359 UnGNUify the codebase 2017-03-10 23:41:24 -05:00
Drew DeVault
9ad1e6b40f Handle malloc failure in ipc_recv_response 2016-12-15 19:01:40 -05:00
Drew DeVault
416417a54c Reorganize includes 2016-09-01 08:18:37 -04:00
Johannes Lundberg
949933c5c3 Fix to make ipc client code FreeBSD compatible. 2016-08-30 16:59:36 -07:00
Eric Engestrom
aece36cd22 common: fix potential buffer overflow 2016-05-01 13:57:23 +01:00
Mikkel Oscar Lyderik
1d010afbf7 Abort when receiving 0 bytes in IPC call
When sway crashes a swaybar process is sometimes left behind running at
100% CPU. This was caused by the swaybar trying to retrieve an IPC
response from the closed sway socket.

This patch fixes the problem by aborting when the socket has been closed
(recv return 0).

Fix #528
2016-03-22 11:27:39 +01:00
Mikkel Oscar Lyderik
7298a9c67a Add type to returned response.
Makes `ipc_recv_response` return a struct with size, type and payload
rather than just the payload string.

This is useful if the type has to be checked on the client.
2016-01-03 20:40:50 +01:00
Drew DeVault
e277d4e094 Subscribe to workspace change events and redraw 2015-12-13 16:04:54 -05:00
Drew DeVault
8b1de6df30 Fix incorrect #include on ipc-client.c 2015-11-28 08:57:45 -05:00
Drew DeVault
062c74b7d0 Add command line to swaygrab
Also modifies IPC client so that we can work with persistent
connections.
2015-11-27 10:10:29 -05:00
Drew DeVault
27f03c705d Move IPC client into common, refactor IPC 2015-11-27 09:50:04 -05:00