Skip to content
This repository has been archived by the owner on Aug 9, 2018. It is now read-only.

I think the commit 04794ed1757738b3b178a4fbf7601701d16a1a3d is wrong #4

Closed
yuyuyu101 opened this issue Dec 17, 2012 · 2 comments
Closed

Comments

@yuyuyu101
Copy link

I am sorry my last issue the source is already changed , but the commit 04794ed1757738b3b178a4fbf7601701d16a1a3d I think not repair the problem. I still meet problem but different from pervious issue.

When I clone the newest commit and rebuild, I run shell below:

./beansdb
all ready.
key 20 (#8) should not in this tree (1:1)
key 21 (#8) should not in this tree (1:1)
key 21 (#8) should not in this tree (1:1)
key 9050 (#2) should not in this tree (1:3)
Segmentation fault: 11

My client script is

from socket import socket
from time import time

s = socket()
def cons(command, key, value):
    return '%s %s 0 0 %d\r\n%s\r\n' % (command, key, len(value), value)

port = 7900

start = time()
s.connect(('localhost', port))
total = 0
for i in range(1000000):
    message = cons('set', str(i), 'asdfadsfasdf')
    try:
        s.send(message)
        s.recv(100)
        total += 1
    except:
        s = socket()
        s.connect(('localhost', port))
        print total
        total = 0
end = time()
print end-start

The goal script writed I only want to test something .

        loop.nready --;
        int fd = loop.fired[loop.nready];
        conn *c = loop.conns[fd];
        if (c == NULL){
            fprintf(stderr, "Bug: conn %d should not be NULL\n", fd);
            delete_event(fd);
            close(fd);
            goto AGAIN;
        }
        //loop.conns[fd] = NULL; 
        pthread_mutex_unlock(&leader);

        if (drive_machine(c)) {
            if (update_event(fd, c->ev_flags, c)) conn_close(c);
        }

I think commet
loop.conns[fd] = NULL;
is useless.

When worker1 is parsing the command from client, worker2 get the same connection and enter drive_machine. The connection is mastered by two workers!!

osx 10.8.2
python 2.7

@davies
Copy link
Contributor

davies commented Dec 17, 2012

OK, I see it.

Commit 04794ed only fix the problem under Linux 2.6 with epoll, but not with kqueue, because epoll has flag EPOLLONESHOT for one-shot event, I will fix it for kqueue.

@davies
Copy link
Contributor

davies commented Dec 17, 2012

fixed in 2917aa0

@davies davies closed this as completed Dec 17, 2012
alexband pushed a commit to alexband/beansdb that referenced this issue Mar 17, 2014
do something gentle edit for refoctoring
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants