From f491fcc6f91c7dd71685519def7eddb1b0b9f676 Mon Sep 17 00:00:00 2001 From: Levi Neely <141506390+lneely@users.noreply.github.com> Date: Sat, 1 Mar 2025 18:02:40 +0100 Subject: [PATCH] pdevmon namespace and cleanup --- pclsync/{pdevice_monitor.c => pdevmon.c} | 26 +++++++++++------------- pclsync/{pdevice_monitor.h => pdevmon.h} | 4 +++- pclsync/psynclib.c | 4 ++-- 3 files changed, 17 insertions(+), 17 deletions(-) rename pclsync/{pdevice_monitor.c => pdevmon.c} (86%) rename pclsync/{pdevice_monitor.h => pdevmon.h} (98%) diff --git a/pclsync/pdevice_monitor.c b/pclsync/pdevmon.c similarity index 86% rename from pclsync/pdevice_monitor.c rename to pclsync/pdevmon.c index dd120a9..2d94215 100644 --- a/pclsync/pdevice_monitor.c +++ b/pclsync/pdevmon.c @@ -39,7 +39,7 @@ #include "prun.h" -#include "pdevice_monitor.h" +#include "pdevmon.h" #include "plocalscan.h" #include "ptimer.h" @@ -48,7 +48,7 @@ static pthread_mutex_t devmon_mutex = PTHREAD_MUTEX_INITIALIZER; static psync_timer_t devmon_activity_timer = NULL; -void devmon_activity_timer_action() { +static void on_timer_activity() { psync_timer_stop(devmon_activity_timer); pthread_mutex_lock(&devmon_mutex); devmon_activity_timer = NULL; @@ -56,19 +56,18 @@ void devmon_activity_timer_action() { psync_restat_sync_folders(); } -void devmon_activity_timer_start() { +static void timer_start() { pthread_mutex_lock(&devmon_mutex); if (!devmon_activity_timer) - devmon_activity_timer = psync_timer_register( - devmon_activity_timer_action, DEV_MONITOR_ACTIVITY_TIMER_INT, NULL); + devmon_activity_timer = psync_timer_register(on_timer_activity, DEV_MONITOR_ACTIVITY_TIMER_INT, NULL); pthread_mutex_unlock(&devmon_mutex); } -void enumerate_devices(struct udev *udev, device_event event) { - devmon_activity_timer_start(); +static void enum_devices(struct udev *udev, device_event event) { + timer_start(); } -void monitor_usb_dev() { +static void monitor_usb() { struct udev *udev; struct udev_device *dev; struct udev_monitor *mon; @@ -106,7 +105,7 @@ void monitor_usb_dev() { select() ensured that this will not block. */ dev = udev_monitor_receive_device(mon); if (dev) { - enumerate_devices(udev, Dev_Event_arrival); + enum_devices(udev, Dev_Event_arrival); } else { // printf("No Device from receive_device(). An error occured.\n"); } @@ -118,12 +117,11 @@ void monitor_usb_dev() { return; } -void device_monitor_thread() { +static void proc_devmon() { debug(D_NOTICE, "Waiting for USB devices connect/disconnect events"); - monitor_usb_dev(); + monitor_usb(); } -void psync_devmon_init() { - prun_thread("libusb handle events completed thread", - device_monitor_thread); +void pdevmon_init() { + prun_thread("libusb handle events completed thread", proc_devmon); } diff --git a/pclsync/pdevice_monitor.h b/pclsync/pdevmon.h similarity index 98% rename from pclsync/pdevice_monitor.h rename to pclsync/pdevmon.h index 3228247..bc7c16b 100644 --- a/pclsync/pdevice_monitor.h +++ b/pclsync/pdevmon.h @@ -37,7 +37,9 @@ #ifdef __cplusplus extern "C" { #endif -void psync_devmon_init(); + +void pdevmon_init(); + #ifdef __cplusplus } #endif diff --git a/pclsync/psynclib.c b/pclsync/psynclib.c index 9e4f4b7..ed786d7 100644 --- a/pclsync/psynclib.c +++ b/pclsync/psynclib.c @@ -49,7 +49,7 @@ #include "pcryptofolder.h" #include "pcontacts.h" #include "pdevice.h" -#include "pdevice_monitor.h" +#include "pdevmon.h" #include "pdiff.h" #include "pdownload.h" #include "pfile.h" @@ -334,7 +334,7 @@ void psync_start_sync(pstatus_change_callback_t status_callback, psync_p2p_init(); if (psync_setting_get_bool(_PS(autostartfs))) psync_fs_start(); - psync_devmon_init(); + pdevmon_init(); } void psync_set_notification_callback(