Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Synchronet
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
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
Main
Synchronet
Commits
73d6ef74
Commit
73d6ef74
authored
21 years ago
by
deuce
Browse files
Options
Downloads
Patches
Plain Diff
Handle SIGHUP for carrier detection rather than polling it.
parent
353082ed
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/odoors/ODKrnl.c
+27
-18
27 additions, 18 deletions
src/odoors/ODKrnl.c
with
27 additions
and
18 deletions
src/odoors/ODKrnl.c
+
27
−
18
View file @
73d6ef74
...
...
@@ -185,10 +185,12 @@ tODResult ODKrnlInitialize(void)
tODResult
Result
=
kODRCSuccess
;
#ifdef ODPLAT_NIX
/* Block SIGHUP for carrier detect use */
sigemptyset
(
&
block
);
sigaddset
(
&
block
,
SIGHUP
);
sigprocmask
(
SIG_BLOCK
,
&
block
,
NULL
);
/* HUP Detection */
act
.
sa_handler
=
sig_no_carrier
;
/* If two HUP signals are recieved, die on the second */
act
.
sa_flags
=
SA_RESETHAND
;
sigemptyset
(
&
(
act
.
sa_mask
));
sigaction
(
SIGHUP
,
&
act
,
NULL
);
/* Run kernel on SIGALRM (Every 1 second) */
act
.
sa_handler
=
sig_run_kernel
;
...
...
@@ -197,31 +199,28 @@ tODResult ODKrnlInitialize(void)
sigaction
(
SIGALRM
,
&
act
,
NULL
);
itv
.
it_interval
.
tv_sec
=
1
;
itv
.
it_interval
.
tv_usec
=
0
;
itv
.
it_value
.
tv_sec
=
0
;
itv
.
it_value
.
tv_usec
=
25000
0
;
itv
.
it_value
.
tv_sec
=
1
;
itv
.
it_value
.
tv_usec
=
0
;
setitimer
(
ITIMER_REAL
,
&
itv
,
NULL
);
/* Make sure SIGALRM is unblocked */
sigemptyset
(
&
block
);
sigaddset
(
&
block
,
SIGALRM
);
sigprocmask
(
SIG_UNBLOCK
,
&
block
,
NULL
);
/* Make stdin signal driven. */
act
.
sa_handler
=
sig_get_char
;
act
.
sa_flags
=
0
;
sigemptyset
(
&
(
act
.
sa_mask
));
sigaction
(
SIGIO
,
&
act
,
NULL
);
/* Make sure SIGIO is unblocked */
sigemptyset
(
&
block
);
sigaddset
(
&
block
,
SIGIO
);
sigprocmask
(
SIG_UNBLOCK
,
&
block
,
NULL
);
/* Have SIGIO signales delivered to this process */
fcntl
(
0
,
F_SETOWN
,
getpid
());
/* Enable SIGIO when read possible on stdin */
fcntl
(
0
,
F_SETFL
,
fcntl
(
0
,
F_GETFL
)
|
O_ASYNC
);
/* Make sure SIGHUP, SIGALRM, and SIGIO are unblocked */
sigemptyset
(
&
block
);
sigaddset
(
&
block
,
SIGHUP
);
sigaddset
(
&
block
,
SIGALRN
);
sigaddset
(
&
block
,
SIGIO
);
sigprocmask
(
SIG_UNBLOCK
,
&
block
,
NULL
);
#endif
/* Initialize time of next status update and next time deduction. */
...
...
@@ -368,6 +367,7 @@ ODAPIDEF void ODCALL od_kernel(void)
#ifndef OD_MULTITHREADED
/* If not operating in local mode, then perform remote-mode specific */
/* activies. */
#ifndef ODPLAT_NIX
/* On *nix, this is handled by signals */
if
(
od_control
.
baud
!=
0
)
{
/* If carrier detection is enabled, then shutdown OpenDoors if */
...
...
@@ -381,15 +381,14 @@ ODAPIDEF void ODCALL od_kernel(void)
}
}
#ifndef ODPLAT_NIX
/* On *nix, this is handled by a signal */
/* Loop, obtaining any new characters from the serial port and */
/* adding them to the common local/remote input queue. */
while
(
ODComGetByte
(
hSerialPort
,
&
ch
,
FALSE
)
==
kODRCSuccess
)
{
ODKrnlHandleReceivedChar
(
ch
,
TRUE
);
}
#endif
}
#endif
#ifdef ODPLAT_DOS
check_keyboard_again:
...
...
@@ -698,7 +697,9 @@ statup:
ODKrnlTimeUpdate
();
#ifndef ODPLAT_NIX
ODTimerStart
(
&
RunKernelTimer
,
250
);
#endif
OD_API_EXIT
();
...
...
@@ -1647,4 +1648,12 @@ static void sig_get_char(int sig)
ODKrnlHandleReceivedChar
(
ch
,
TRUE
);
}
}
static
void
sig_no_carrier
(
int
sig
)
{
if
(
od_control
.
baud
!=
0
)
{
ODKrnlForceOpenDoorsShutdown
(
ERRORLEVEL_NOCARRIER
);
}
}
#endif
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