Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F151219912
D7270.id18626.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D7270.id18626.diff
View Options
Index: sys/dev/pty/pty.c
===================================================================
--- sys/dev/pty/pty.c
+++ sys/dev/pty/pty.c
@@ -52,10 +52,10 @@
* binary emulation.
*/
-static unsigned int pty_warningcnt = 1;
+static unsigned pty_warningcnt = 1;
SYSCTL_UINT(_kern, OID_AUTO, tty_pty_warningcnt, CTLFLAG_RW,
- &pty_warningcnt, 0,
- "Warnings that will be triggered upon legacy PTY allocation");
+ &pty_warningcnt, 0,
+ "Warnings that will be triggered upon legacy PTY allocation");
static int
ptydev_fdopen(struct cdev *dev, int fflags, struct thread *td, struct file *fp)
@@ -77,12 +77,7 @@
}
/* Raise a warning when a legacy PTY has been allocated. */
- if (pty_warningcnt > 0) {
- pty_warningcnt--;
- log(LOG_INFO, "pid %d (%s) is using legacy pty devices%s\n",
- td->td_proc->p_pid, td->td_name,
- pty_warningcnt ? "" : " - not logging anymore");
- }
+ counted_warning(&pty_warningcnt, "is using legacy pty devices");
return (0);
}
Index: sys/kern/subr_prf.c
===================================================================
--- sys/kern/subr_prf.c
+++ sys/kern/subr_prf.c
@@ -1196,3 +1196,22 @@
}
}
+void
+counted_warning(unsigned *counter, const char *msg)
+{
+ struct thread *td;
+ unsigned c;
+
+ for (;;) {
+ c = *counter;
+ if (c == 0)
+ break;
+ if (atomic_cmpset_int(counter, c, c - 1)) {
+ td = curthread;
+ log(LOG_INFO, "pid %d (%s) %s%s\n",
+ td->td_proc->p_pid, td->td_name, msg,
+ c > 1 ? "" : " - not logging anymore");
+ break;
+ }
+ }
+}
Index: sys/sys/systm.h
===================================================================
--- sys/sys/systm.h
+++ sys/sys/systm.h
@@ -447,4 +447,6 @@
extern void (*softdep_ast_cleanup)(void);
+void counted_warning(unsigned *counter, const char *msg);
+
#endif /* !_SYS_SYSTM_H_ */
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Apr 7, 10:42 PM (8 h, 52 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
31053001
Default Alt Text
D7270.id18626.diff (1 KB)
Attached To
Mode
D7270: counted_warning(9) KPI
Attached
Detach File
Event Timeline
Log In to Comment