- pthread_mutex_lock (&size_mutex);
- type_list_incr (&size, type, bytes);
- pthread_mutex_unlock (&size_mutex);
- }
- else if ('s' == line[0]) { /* s:<value> */
- pthread_mutex_lock (&score_mutex);
- score = (score * (double)score_count + atof (line + 2))
- / (double)(score_count + 1);
- ++score_count;
- pthread_mutex_unlock (&score_mutex);
- }
- else if ('c' == line[0]) { /* c:<type1>[,<type2>,...] */
- char *ptr = NULL;
- char *type = strtok_r (line + 2, ",", &ptr);
-
- do {
- pthread_mutex_lock (&check_mutex);
- type_list_incr (&check, type, 1);
- pthread_mutex_unlock (&check_mutex);
- } while (NULL != (type = strtok_r (NULL, ",", &ptr)));
- }
- else {
- syslog (LOG_ERR, "email: unknown type '%c'", line[0]);
+ errno = 0;
+ if (-1 == fcntl (connection->socket, F_GETFL, &flags)) {
+ char errbuf[1024];
+ log_err ("fcntl() failed: %s",
+ sstrerror (errno, errbuf, sizeof (errbuf)));
+ loop = 0;
+ }
+
+ errno = 0;
+ if (-1 == fcntl (connection->socket, F_SETFL, flags | O_NONBLOCK)) {
+ char errbuf[1024];
+ log_err ("fcntl() failed: %s",
+ sstrerror (errno, errbuf, sizeof (errbuf)));
+ loop = 0;
+ }