daniel-p-carvalho commented on code in PR #3782:
URL: https://github.com/apache/nuttx-apps/pull/3782#discussion_r4057397965
##########
netutils/ptpd/ptpd.c:
##########
@@ -42,6 +42,9 @@
#include <sched.h>
#include <assert.h>
#include <errno.h>
+#ifdef CONFIG_BUILD_FLAT
Review Comment:
Done, `<semaphore.h>` is included unconditionally now.
##########
netutils/ptpd/ptpd.c:
##########
@@ -67,6 +70,16 @@
* Private Types
****************************************************************************/
+#ifdef CONFIG_BUILD_FLAT
+/* Carrier structure for querying PTPD status in flat build mode */
+
+struct ptpd_statusreq_s
+{
+ FAR sem_t *done;
+ FAR struct ptpd_status_s *dest;
Review Comment:
Done. `done` and `dest` are members by value now (`sem_t done; struct
ptpd_status_s dest;`). `ptpd_status()` copies `dest` to the buffer of the
caller after the semaphore is posted.
##########
netutils/ptpd/ptpd.c:
##########
@@ -75,6 +88,9 @@ struct ptp_state_s
bool stop;
bool dump; /* Set by SIGUSR1, checked in main loop */
+#ifdef CONFIG_BUILD_FLAT
+ struct ptpd_statusreq_s status_req;
Review Comment:
Done. `status_req` in `struct ptp_state_s` is a pointer now. The signal
handler only stores the pointer it gets in `si_value.sival_ptr`, it no longer
copies the structure, and `ptp_process_statusreq()` fills the request it points
to, clears the pointer and posts the semaphore.
One more change that comes with it: `ptpd` keeps that pointer until it
answers, which can be after `ptpd_status()` gave up waiting after one second
and returned, so the request cannot be on the stack of the caller. It is a
static object now, and a mutex lets only one caller use it at a time. A late
answer to a request that timed out is dropped before the next one is sent. This
also means that two callers at the same time are served one after the other
instead of the second overwriting the first.
##########
netutils/ptpd/ptpd.c:
##########
@@ -2191,6 +2246,9 @@ int ptpd_start(FAR const struct ptpd_config_s *config)
ptp_periodic_send(state);
state->selected_source_valid = is_selected_source_valid(state);
+#ifdef CONFIG_BUILD_FLAT
+ ptp_process_statusreq(state);
+#endif
ptp_dump_status_file(state);
Review Comment:
Done. In flat builds only `ptp_process_statusreq()` is called and in the
other builds only `ptp_dump_status_file()`. The dump function and the `dump`
flag are built only for the non-flat case, so there is no unused function in
flat builds.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]