Skip to content

Commit d4524ed

Browse files
committed
SWPTP-1500: do not block on msg pool for clock feed sync
1 parent 9eb5358 commit d4524ed

File tree

4 files changed

+11
-8
lines changed

4 files changed

+11
-8
lines changed

src/include/sfptpd_multicast.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,14 @@ int sfptpd_multicast_unpublish(uint32_t msg_id);
5353
* @param hdr Header of the message to be sent
5454
* @param msg_id The message id of the multicast group
5555
* @param pool Pool from which to allocate the replicated messages
56+
* @param wait Wait for free message slots, else abort if not enough
5657
* @return 0 on success or errno
5758
*/
5859
int sfptpd_multicast_send(sfptpd_msg_hdr_t *hdr,
5960
uint32_t msg_id,
60-
enum sfptpd_msg_pool_id pool);
61-
#define SFPTPD_MULTICAST_SEND(msg, msg_id, pool) \
62-
sfptpd_multicast_send(&((msg)->hdr), (msg_id), (pool))
61+
enum sfptpd_msg_pool_id pool,
62+
bool wait);
63+
#define SFPTPD_MULTICAST_SEND(msg, msg_id, pool, wait) \
64+
sfptpd_multicast_send(&((msg)->hdr), (msg_id), (pool), (wait))
6365

6466
#endif /* _SFPTPD_MULTICAST_H */

src/sfptpd_clockfeed.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ static void clockfeed_send_sync_event(struct sfptpd_clockfeed *clockfeed)
290290
SFPTPD_MSG_INIT(msg);
291291
SFPTPD_MULTICAST_SEND(&msg,
292292
SFPTPD_CLOCKFEED_MSG_SYNC_EVENT,
293-
SFPTPD_MSG_POOL_LOCAL);
293+
SFPTPD_MSG_POOL_LOCAL, false);
294294
}
295295

296296
static void clockfeed_reap_zombies(struct sfptpd_clockfeed *module,

src/sfptpd_main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,7 @@ static void on_control_socket_fd(int fd)
744744
SFPTPD_MSG_INIT(msg.app);
745745
SFPTPD_MULTICAST_SEND(&msg.app,
746746
SFPTPD_APP_MSG_DUMP_TABLES,
747-
SFPTPD_MSG_POOL_GLOBAL);
747+
SFPTPD_MSG_POOL_GLOBAL, false);
748748
break;
749749
case CONTROL_PID_ADJUST:
750750
/* Adjust PID controller coefficients */
@@ -762,7 +762,7 @@ static void on_control_socket_fd(int fd)
762762
msg.servo.u.pid_adjust.reset = param.pid_adjust.reset;
763763
SFPTPD_MULTICAST_SEND(&msg.servo,
764764
SFPTPD_SERVO_MSG_PID_ADJUST,
765-
SFPTPD_MSG_POOL_GLOBAL);
765+
SFPTPD_MSG_POOL_GLOBAL, true);
766766
break;
767767
}
768768
}

src/sfptpd_multicast.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,8 @@ int sfptpd_multicast_unpublish(uint32_t msg_id)
322322

323323
int sfptpd_multicast_send(sfptpd_msg_hdr_t *hdr,
324324
uint32_t msg_id,
325-
enum sfptpd_msg_pool_id pool)
325+
enum sfptpd_msg_pool_id pool,
326+
bool wait)
326327
{
327328
struct multicast_group *group;
328329
struct multicast_user *user;
@@ -359,7 +360,7 @@ int sfptpd_multicast_send(sfptpd_msg_hdr_t *hdr,
359360
SLIST_FOREACH(user, &group->subscribers, users) {
360361
assert(user->magic == MULTICAST_USER_MAGIC);
361362
dests[i].thread = user->thread;
362-
dests[i].msg = sfptpd_msg_alloc(pool, true);
363+
dests[i].msg = sfptpd_msg_alloc(pool, wait);
363364
if (dests[i++].msg == NULL) {
364365
rc = errno;
365366
break;

0 commit comments

Comments
 (0)