[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH] tools/oxenstored: port XS_INTRODUCE evtchn rebind function from cxenstored



On 20/08/2019 13:11, Christian Lindig wrote:
> 
> 
>> On 20 Aug 2019, at 11:45, Igor Druzhinin <igor.druzhinin@xxxxxxxxxx> wrote:
>>
>> On 20/08/2019 09:21, Christian Lindig wrote:
>>>> +                  if (Domain.get_mfn edom) = mfn && 
>>>> (Connections.find_domain cons domid) != con then begin
>>>
>>> This should use <> instead of != because != is pointer inequality in OCaml. 
>>> The parentheses are not strictly necessary because function application has 
>>> precedence. So:
>>>
>>>     if Domain.get_mfn edom = mfn && Connections.find_domain cons domid <> 
>>> con then begin
>>>
>>
>> But I actually want to compare pointers here - the idea is that the
>> connection object in the hashtable indexed by domid is not the same as
>> connection that we got XS_INTRODUCE message from. (see
>> tools/xenstore/xenstrored_domain.c)
> 
> In your code, a != b is true, if a and b have identical structure but 
> different addresses. I strongly suspect that two connection values should 
> have different structure to be considered different, not just different 
> addresses. When a <> b is true, it implies a != b. So using a <> b is 
> safe(r). By using != you would rely on an invariant that every connection 
> (con) exists only once and is never copied.
> 

Connection is a complex object (has various counters and internal
structures) and I don't think simple field by field comparison (is <>
just that in Ocaml?) is appropriate here.

con is passed into that function from xenstored.ml where it's extracted
from the same hashtable (Connections) so it's actually the exactly same
object. There are other examples in connections.ml where pointer
comparison is used to compare connections.

Igor

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.