[PATCH 2/2] Optimize signal setting in alert() function.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Moving signal setting in Monitor.c out of the alert() function
makes it more clear as it was set to ignore SIGPIPE every time
alert() was called, but was never set back to default again.
Now SIGPIPE is ignored for whole duration of the program just once.

Signed-off-by: Lukasz Florczak <lukasz.florczak@xxxxxxxxxxxxxxx>
---
 Monitor.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/Monitor.c b/Monitor.c
index 40388b64..222568cb 100644
--- a/Monitor.c
+++ b/Monitor.c
@@ -159,6 +159,9 @@ int Monitor(struct mddev_dev *devlist,
 	info.mailfrom = mailfrom;
 	info.dosyslog = dosyslog;
 
+	if (info.mailaddr)
+		signal_s(SIGPIPE, SIG_IGN);
+
 	if (share){
 		if (check_one_sharer(c->scan))
 			return 1;
@@ -436,8 +439,7 @@ static void alert(char *event, char *dev, char *disc, struct alert_info *info)
 			char hname[256];
 
 			gethostname(hname, sizeof(hname));
-			signal_s(SIGPIPE, SIG_IGN);
-			
+
 			if (info->mailfrom)
 				fprintf(mp, "From: %s\n", info->mailfrom);
 			else
-- 
2.26.2




[Index of Archives]     [Linux RAID Wiki]     [ATA RAID]     [Linux SCSI Target Infrastructure]     [Linux Block]     [Linux IDE]     [Linux SCSI]     [Linux Hams]     [Device Mapper]     [Device Mapper Cryptographics]     [Kernel]     [Linux Admin]     [Linux Net]     [GFS]     [RPM]     [git]     [Yosemite Forum]


  Powered by Linux