--- a/src/core/ngx_connection.c	2017-11-24 18:02:37.351173463 +0300
+++ b/src/core/ngx_connection.c	2017-11-24 18:03:25.536739089 +0300
@@ -952,6 +952,32 @@
         }
 
 #endif
+
+#if (NGX_HAVE_SCHED_SETAFFINITY) && (SO_INCOMING_CPU)
+        {
+            ngx_cpuset_t *cpu_affinity = ngx_get_cpu_affinity(ls[i].worker);
+            ngx_int_t cpu;
+            socklen_t clen = sizeof(cpu);
+            for (cpu = 0; cpu < CPU_SETSIZE; cpu++) {
+                if (CPU_ISSET(cpu, cpu_affinity)) {
+                    ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0,
+                                  "setsockopt(SO_INCOMING_CPU): using cpu #%ui"
+                                  " for socket with worker #%ui", cpu, ls[i].worker);
+                    if (setsockopt(ls[i].fd, SOL_SOCKET, SO_INCOMING_CPU, &cpu, clen)
+                        == -1)
+                    {
+                        ngx_log_error(NGX_LOG_WARN, cycle->log, ngx_socket_errno,
+                            "setsockopt(SO_INCOMING_CPU) "
+                            "for worker socket #%ui failed, ignored",
+                            cpu);
+                      
+                    }
+                    break;
+                }
+            }
+                    
+        }
+#endif
     }
 
     return;
