// File: /workspace/github_cpp_makefile_star2_O2/lega911[P]ijson/src/connect.cpp
// Function: Connect::pub(ISlice&)
void Connect::pub(ISlice &name) {
    QueueLine *ql = server->get_queue(name);
    if(!ql) {
        if(server->log & 4) std::cout << ltime() << "404 no method " << name.as_string() << std::endl;
        this->send.status("404 Not Found")->done(-32601);
        return;
    }

    auto *dm = new DirectMessage();
    dm->link();
    Buffer *data = &dm->data;
    data->add("HTTP/1.1 200 OK\r\nConnection: keep-alive\r\nName: ");
    data->add(name);
    data->add("\r\nAsync: true\r\n");
    if(body.size() == 0) {
        data->add("Content-Length: 0\r\n\r\n");
    } else {
        data->add("Content-Length: ");
        data->add_number(body.size());
        data->add("\r\n\r\n");
        data->add(body);
    };

    LOCK _l(ql->workers.lock);
    auto *item = ql->workers.head;
    for(;item;item=item->next) {
        auto *worker = item->conn;

        bool send = false;
        if(worker->status == Status::worker_wait_job) {
            worker->mutex.lock();
            if(worker->status == Status::worker_wait_job) {
                worker->status = Status::busy;
                send = true;
            }
            worker->mutex.unlock();
        };

        if(send) {
            if(worker->worker_mode) worker->status = Status::worker_mode_async;
            else worker->status = Status::net;

            dm->link();
            worker->direct_message.push_back(dm);
            worker->write_mode(true);
        } else if(worker->noid) {
            dm->link();
            worker->direct_message.push_back(dm);
        }
    }
    this->send.status("200 OK")->done(1);
    if(dm->unlink() == 0) delete dm;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, %r15
movq %rdi, %rbx
movq 0x48(%rdi), %rdi
movq (%rsi), %rsi
movl 0x8(%r15), %edx
xorl %ecx, %ecx
callq 0x104d6
testq %rax, %rax
je 0xc285
movq %rax, %r14
pushq $0x40
popq %rdi
callq 0xfb38
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movups %xmm0, 0x10(%rax)
movups %xmm0, 0x20(%rax)
movups %xmm0, 0x30(%rax)
movq %rax, -0x50(%rbp)
lock
incl 0x3c(%rax)
movq -0x50(%rbp), %r12
addq $0x28, %r12
leaq 0xc4b9(%rip), %rsi      # 0x186cb
movq %r12, %rdi
callq 0xd5ee
movq %r12, %rdi
movq %r15, %rsi
callq 0xd300
leaq 0xc4cf(%rip), %rsi      # 0x186fb
movq %r12, %rdi
callq 0xd5ee
cmpl $0x0, 0xd8(%rbx)
je 0xc308
leaq 0xd0(%rbx), %r15
leaq 0xc4d2(%rip), %rsi      # 0x18721
movq %r12, %rdi
callq 0xd5ee
movslq 0xd8(%rbx), %rsi
movq %r12, %rdi
callq 0xd54a
leaq 0xc4af(%rip), %rsi      # 0x1871c
movq %r12, %rdi
callq 0xd5ee
movq %r12, %rdi
movq %r15, %rsi
callq 0xd300
jmp 0xc317
movq 0x48(%rbx), %rax
testb $0x4, 0x20(%rax)
je 0xc2e3
callq 0x16a89
movq 0x13d35(%rip), %rdi     # 0x1ffd0
movq %rax, %rsi
callq 0xa2e0
leaq 0xc404(%rip), %rsi      # 0x186ae
movq %rax, %rdi
callq 0xa2e0
movq %rax, %r14
leaq -0x50(%rbp), %r12
pushq $-0x1
popq %rdx
movq %r12, %rdi
movq %r15, %rsi
callq 0xd636
movq %r14, %rdi
movq %r12, %rsi
callq 0xa280
movq %rax, %rdi
callq 0xa160
leaq -0x50(%rbp), %rdi
callq 0xa130
addq $0x18, %rbx
leaq 0xc3cf(%rip), %rsi      # 0x186bd
movq %rbx, %rdi
callq 0xb93e
movq %rbx, %rdi
movl $0xffff80a7, %esi       # imm = 0xFFFF80A7
callq 0xb9b2
jmp 0xc430
leaq 0xc3fc(%rip), %rsi      # 0x1870b
movq %r12, %rdi
callq 0xd5ee
leaq 0x58(%r14), %rdi
movq %rdi, -0x30(%rbp)
callq 0xd764
subq $-0x80, %r14
leaq -0x50(%rbp), %r12
movq (%r14), %r14
testq %r14, %r14
je 0xc3e2
movq 0x18(%r14), %r15
cmpl $0x1, 0xcc(%r15)
jne 0xc3b5
leaq 0x50(%r15), %r13
movq %r13, %rdi
callq 0xd764
cmpl $0x1, 0xcc(%r15)
jne 0xc3ad
movl $0x5, 0xcc(%r15)
movq %r13, %rdi
callq 0xa220
cmpb $0x0, 0xf3(%r15)
movl $0x0, %eax
pushq $0x6
popq %rcx
cmovnel %ecx, %eax
movl %eax, 0xcc(%r15)
movq -0x50(%rbp), %rax
lock
incl 0x3c(%rax)
leaq 0x190(%r15), %rdi
movq %r12, %rsi
callq 0xd77a
movq %r15, %rdi
pushq $0x1
popq %rsi
callq 0xa8dc
jmp 0xc3d9
movq %r13, %rdi
callq 0xa220
cmpb $0x1, 0xf1(%r15)
jne 0xc3d9
movq -0x50(%rbp), %rax
lock
incl 0x3c(%rax)
addq $0x190, %r15            # imm = 0x190
movq %r15, %rdi
movq %r12, %rsi
callq 0xd77a
addq $0x10, %r14
jmp 0xc32c
addq $0x18, %rbx
leaq 0xbe4c(%rip), %rsi      # 0x18239
movq %rbx, %rdi
callq 0xb93e
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0xb9b2
movq -0x50(%rbp), %rax
lock
decl 0x3c(%rax)
jne 0xc427
movq -0x50(%rbp), %rbx
testq %rbx, %rbx
je 0xc41c
leaq 0x28(%rbx), %rdi
callq 0xd6dc
pushq $0x40
popq %rsi
movq %rbx, %rdi
callq 0xa300
movq -0x30(%rbp), %rdi
callq 0xa220
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0xa130
jmp 0xc45b
jmp 0xc44f
movq %rax, %rbx
movq -0x30(%rbp), %rdi
callq 0xa220
movq %rbx, %rdi
callq 0xa470
nop