Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
cta
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
dCache
cta
Commits
ec892663
Commit
ec892663
authored
13 years ago
by
Sebastien Ponce
Browse files
Options
Downloads
Patches
Plain Diff
Fixed syslog handling on MACOS
parent
ca7e8737
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dlf/dlf_lib.c
+20
-7
20 additions, 7 deletions
dlf/dlf_lib.c
with
20 additions
and
7 deletions
dlf/dlf_lib.c
+
20
−
7
View file @
ec892663
...
...
@@ -37,8 +37,6 @@
#include
<mach/mach.h>
#endif
#define _PATH_LOG "/dev/log"
/* Global variables */
static
char
*
messages
[
DLF_MAX_MSGTEXTS
];
static
int
initialized
=
0
;
...
...
@@ -425,7 +423,7 @@ static int build_syslog_header(char *buffer,
int
len
=
snprintf
(
buffer
,
buflen
,
"<%d>"
,
priority
);
localtime_r
(
&
(
tv
->
tv_sec
),
&
tmp
);
len
+=
strftime
(
buffer
+
len
,
buflen
-
len
,
"%Y-%m-%dT%T"
,
&
tmp
);
len
+=
snprintf
(
buffer
+
len
,
buflen
-
len
,
".%ld"
,
tv
->
tv_usec
);
len
+=
snprintf
(
buffer
+
len
,
buflen
-
len
,
".%
06
ld"
,
(
unsigned
long
)
tv
->
tv_usec
);
len
+=
strftime
(
buffer
+
len
,
buflen
-
len
,
"%z: "
,
&
tmp
);
// dirty trick to have the proper timezone format (':' between hh and mm)
buffer
[
len
-
2
]
=
buffer
[
len
-
3
];
...
...
@@ -717,7 +715,17 @@ static void dlf_openlog() {
(
void
)
close
(
LogFile
);
LogFile
=
-
1
;
}
else
connected
=
1
;
#ifdef __APPLE__
// MAC has has no MSG_NOSIGNAL
// but >= 10.2 comes with SO_NOSIGPIPE
int
set
=
1
;
if
(
0
!=
setsockopt
(
LogFile
,
SOL_SOCKET
,
SO_NOSIGPIPE
,
&
set
,
sizeof
(
int
)))
{
(
void
)
close
(
LogFile
);
LogFile
=
-
1
;
return
;
}
#endif
connected
=
1
;
}
}
...
...
@@ -738,20 +746,25 @@ static void dlf_closelog(void) {
* especially play with the timestamp
*---------------------------------------------------------------------------*/
static
void
dlf_syslog
(
char
*
msg
,
int
msglen
)
{
int
send_flags
=
MSG_NOSIGNAL
;
#ifdef __APPLE__
// MAC has has no MSG_NOSIGNAL
// but >= 10.2 comes with SO_NOSIGPIPE
send_flags
=
0
;
#endif
/* enter critical section */
pthread_mutex_lock
(
&
syslog_lock
);
/* Get connected, output the message to the local logger. */
if
(
!
connected
)
dlf_openlog
();
if
(
!
connected
||
send
(
LogFile
,
msg
,
msglen
,
MSG_NOSIGNAL
)
<
0
)
{
if
(
!
connected
||
send
(
LogFile
,
msg
,
msglen
,
send_flags
)
<
0
)
{
if
(
connected
)
{
/* Try to reopen the syslog connection. Maybe it went down. */
dlf_closelog
();
dlf_openlog
();
}
if
(
!
connected
||
send
(
LogFile
,
msg
,
msglen
,
MSG_NOSIGNAL
)
<
0
)
{
if
(
!
connected
||
send
(
LogFile
,
msg
,
msglen
,
send_flags
)
<
0
)
{
dlf_closelog
();
/* attempt re-open next time */
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment