(2010/02/06 20:26), Trond Norbye wrote:
> 
> On Feb 5, 2010, at 4:01 AM, KaiGai Kohei wrote:
> 
>> (2010/02/05 11:40), KaiGai Kohei wrote:
>>> (2010/02/04 18:32), Toru Maesaka wrote:
>>>> Hi!
>>>>
>>>> Thanks for your proof of concept.
>>>>
>>>>>  From observing your patch, you should be able to develop this as an
>>>> engine once we make changes to the modular engine subsystem based on
>>>> your feedback. Your feedback on get() being called inside another
>>>> function is a good point (thanks!) and I believe some of us have come
>>>> to an agreement to refactor that area. As for getting your hands on
>>>> the connection socket, Trond is willing to add it to the API.
>>>
>>> This is an off topic.
>>
>> And, one more off topic.
>>
>> Is the do_add_delta() really thread safe?
> 
> Yes it is thread safe in the context it is called.

Is it actually thread safe?

Also see the diagram.

 Thread-A                      Thread-B
----o-----------------------------o-----
    |                             |
    V                             |
process_get_command()             |
    |                             |
    V                             |
item_get()                        V
- Lock mutex()                 process_arithmetic_command()
- do_item_get()                   |
- Unlock mutex()                  V
    |                          add_delta()
    V                            - Lock mutex()
add_iov(c, ITEM_data(it),...)    - do_add_delta()
    |                                |
    V                                V
 transmit()                        memcpy()
    |                                |
    |                                V
    |                            - Unlock mutex()
    |                                |
    V                                V
-----------------------------------------

The do_item_get() returns the specified item object with reference
counter increment. It is a reference to the item object, not a copy.

What I wanted to point out is there is a possibility transmit() can
be called during thread-B executes memcpy().
The &c->msglist[c->msgcurr] may refer the item to be modified in
do_add_delta(), and it may be sent the buffer in updating.

Am I missing something?

Thanks,
-- 
OSS Platform Development Division, NEC
KaiGai Kohei <[email protected]>

Reply via email to