retry if socket if flooded

This commit is contained in:
Felix Kratz 2021-09-06 15:17:15 +02:00
parent 182dc3a1c7
commit 6e4a349a9c
2 changed files with 9 additions and 10 deletions

View file

@ -13,12 +13,7 @@ all: clean $(BINS)
install: clean $(BINS)
ln ./bin/sketchybar /usr/local/bin/sketchybar
mkdir ~/.config/sketchybar
cp sketchybarrc ~/.config/sketchybar/sketchybarrc
cp -r plugins ~/.config/sketchybar
chmod +x ~/.config/sketchybar/sketchybarrc
chmod +x ~/.config/sketchybar/plugins/*
echo "Install complete..."
echo "Install complete... Do not forget to setup the configuration file."
uninstall: clean
rm /usr/local/bin/sketchybar

View file

@ -46,8 +46,10 @@ static int client_send_message(int argc, char **argv) {
char socket_file[MAXLEN];
snprintf(socket_file, sizeof(socket_file), SOCKET_PATH_FMT, user);
if (!socket_connect_un(&sockfd, socket_file)) {
error("sketchybar-msg: failed to connect to socket..\n");
int count = 0;
while (!socket_connect_un(&sockfd, socket_file)) {
count++;
if (count > 100) error("sketchybar-msg: failed to connect to socket..\n");
}
int message_length = argc;
@ -68,8 +70,10 @@ static int client_send_message(int argc, char **argv) {
}
*temp++ = '\0';
if (!socket_write_bytes(sockfd, message, message_length)) {
error("sketchybar-msg: failed to send data..\n");
count = 0;
while (!socket_write_bytes(sockfd, message, message_length)) {
count++;
if (count > 100) error("sketchybar-msg: failed to send data..\n");
}
shutdown(sockfd, SHUT_WR);