Skip to content

Commit 34e7563

Browse files
jonchamUnityAlex
authored andcommitted
Limit console spam from warning (case 1238954)
Emitting error 100 times is plenty.
1 parent e95c5f0 commit 34e7563

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

mono/metadata/threadpool-io.c

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ selector_thread_wakeup_drain_pipes (void)
180180
{
181181
gchar buffer [128];
182182
gint received;
183+
static gint warnings_issued = 0;
183184

184185
for (;;) {
185186
#if !defined(HOST_WIN32)
@@ -192,20 +193,30 @@ selector_thread_wakeup_drain_pipes (void)
192193
* some unices (like AIX) send ERESTART, which doesn't
193194
* exist on some other OSes errno
194195
*/
195-
if (errno != EINTR && errno != EAGAIN && errno != ERESTART)
196+
if (errno != EINTR && errno != EAGAIN && errno != ERESTART) {
196197
#else
197-
if (errno != EINTR && errno != EAGAIN)
198+
if (errno != EINTR && errno != EAGAIN) {
198199
#endif
199-
g_warning ("selector_thread_wakeup_drain_pipes: read () failed, error (%d) %s\n", errno, g_strerror (errno));
200+
// limit amount of spam we write
201+
if (warnings_issued < 100) {
202+
g_warning ("selector_thread_wakeup_drain_pipes: read () failed, error (%d) %s\n", errno, g_strerror (errno));
203+
warnings_issued++;
204+
}
205+
}
200206
break;
201207
}
202208
#else
203209
received = recv (threadpool_io->wakeup_pipes [0], buffer, sizeof (buffer), 0);
204210
if (received == 0)
205211
break;
206212
if (received == SOCKET_ERROR) {
207-
if (WSAGetLastError () != WSAEINTR && WSAGetLastError () != WSAEWOULDBLOCK)
208-
g_warning ("selector_thread_wakeup_drain_pipes: recv () failed, error (%d)\n", WSAGetLastError ());
213+
if (WSAGetLastError () != WSAEINTR && WSAGetLastError () != WSAEWOULDBLOCK) {
214+
// limit amount of spam we write
215+
if (warnings_issued < 100) {
216+
g_warning ("selector_thread_wakeup_drain_pipes: recv () failed, error (%d)\n", WSAGetLastError ());
217+
warnings_issued++;
218+
}
219+
}
209220
break;
210221
}
211222
#endif

0 commit comments

Comments
 (0)