File tree 1 file changed +12
-2
lines changed
1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -1973,13 +1973,23 @@ PHP_FUNCTION(socket_set_option)
1973
1973
static struct sock_filter cbpf [8 ] = {0 };
1974
1974
static struct sock_fprog bpfprog ;
1975
1975
1976
+ // TODO: might be a good enough approximation, more native api could be used potentially tough
1977
+ long onln = sysconf (_SC_NPROCESSORS_ONLN );
1978
+
1979
+ if (onln == -1 ) {
1980
+ php_error_docref (NULL , E_WARNING , "Online cores fetching failed" );
1981
+ RETURN_FALSE ;
1982
+ }
1983
+
1976
1984
switch (k ) {
1977
1985
case SKF_AD_CPU :
1978
1986
case SKF_AD_QUEUE :
1979
1987
cbpf [0 ].code = (BPF_LD |BPF_W |BPF_ABS );
1980
1988
cbpf [0 ].k = (uint32_t )(SKF_AD_OFF + k );
1981
- cbpf [1 ].code = (BPF_RET |BPF_A );
1982
- bpfprog .len = 2 ;
1989
+ cbpf [1 ].code = (BPF_ALU | BPF_MOD );
1990
+ cbpf [1 ].k = (uint32_t )(onln );
1991
+ cbpf [2 ].code = (BPF_RET |BPF_A );
1992
+ bpfprog .len = 3 ;
1983
1993
break ;
1984
1994
default :
1985
1995
php_error_docref (NULL , E_WARNING , "Unsupported CBPF filter" );
You can’t perform that action at this time.
0 commit comments