Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

About event loop , where does it run? #327

Open
marol1210 opened this issue Sep 4, 2023 · 0 comments
Open

About event loop , where does it run? #327

marol1210 opened this issue Sep 4, 2023 · 0 comments
Labels
question Further information is requested

Comments

@marol1210
Copy link

marol1210 commented Sep 4, 2023

  1. What did you do? If possible, provide a simple script for reproducing the error.

Reactor threads are created in the Master process to handle client side network connections and network I\O.

So , request callback will execute from reactor thread , then callback function will execute from work process , won't it ?

$workerState = new WorkerState;

$workerState->cacheTable = require __DIR__.'/createSwooleCacheTable.php';
$workerState->timerTable = $timerTable;
$workerState->tables = require __DIR__.'/createSwooleTables.php';


$server->on('request', function ($request, $response) use ($server, $workerState, $serverState) {
    $workerState->lastRequestTime = microtime(true);

    if ($workerState->timerTable) {
        $workerState->timerTable->set($workerState->workerId, [
            'worker_pid' => $workerState->workerPid,
            'time' => time(),
            'fd' => $request->fd,
        ]);
    }

    $workerState->worker->handle(...$workerState->client->marshalRequest(new RequestContext([
        'swooleRequest' => $request,
        'swooleResponse' => $response,
        'publicPath' => $serverState['publicPath'],
        'octaneConfig' => $serverState['octaneConfig'],
    ])));

    if ($workerState->timerTable) {
        $workerState->timerTable->del($workerState->workerId);
    }
});

  1. What did you expect to see?

I don't know  Where  does the `worker`  property value of  $workerState  set  ?   How do it ?



  1. What did you see instead?

I  echo $workerState->workerId  , value is always 12 ,  because dispatch_mode default 2.  but ,  when  worker is setted  and  how?

Can you provide some hints or suggestions for understanding this logic?   thks very mush.


  1. What version of OpenSwoole are you using (show your php --ri openswoole)?
22.0.0


  1. What is your machine environment used (show your uname -a & php -v & gcc -v) ?

`uname -a`
Linux 8a223d4b567a 5.15.90.1-microsoft-standard-WSL2 #1 SMP Fri Jan 27 02:56:13 UTC 2023 x86_64 Linux

`php -v`
PHP 8.1.18 (cli) (built: Apr 14 2023 18:50:03) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.18, Copyright (c) Zend Technologies


`gcc -v`
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-alpine-linux-musl/11.2.1/lto-wrapper
Target: x86_64-alpine-linux-musl
Configured with: /home/buildozer/aports/main/gcc/src/gcc-11.2.1_git20220219/configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --build=x86_64-alpine-linux-musl --host=x86_64-alpine-linux-musl --target=x86_64-alpine-linux-musl --with-pkgversion='Alpine 11.2.1_git20220219' --enable-checking=release --disable-fixed-point --disable-libstdcxx-pch --disable-multilib --disable-nls --disable-werror --disable-symvers --enable-__cxa_atexit --enable-default-pie --enable-default-ssp --enable-cloog-backend --enable-languages=c,c++,d,objc,go,fortran,ada,jit --disable-libssp --disable-libmpx --disable-libmudflap --disable-libsanitizer --enable-shared --enable-threads --enable-tls --enable-host-shared --with-system-zlib --with-linker-hash-style=gnu
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 11.2.1 20220219 (Alpine 11.2.1_git20220219)


You can also try the following OpenSwoole support channels:

@doubaokun doubaokun added the question Further information is requested label Nov 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants