Ticket #978 (closed task: fixed)
[API] introduce reference counting for all modules/objects
| Reported by: | dgollub | Owned by: | dgollub |
|---|---|---|---|
| Priority: | high | Milestone: | OpenSync 0.39 |
| Component: | OpenSync | Version: | 0.38 |
| Severity: | normal | Keywords: | |
| Cc: |
Description
There are still modules/objects without reference-counting. Usually you can identify them since they provide interfaces like osync_XXXX_free().
Task:
- introduce ref-counter in module/object-struct
- implement _ref and _unref functions
- drop osync_xyz_free()
Attachments
Change History
Changed 3 years ago by ianmartin
-
attachment
osync_plugin_env_free_removed.diff
added
comment:1 follow-up: ↓ 4 Changed 3 years ago by ianmartin
- Summary changed from [API] introduce reference counting for all modules/objects to [PATCH] [API] introduce reference counting for all modules/objects
Patch to add reference counting to OSyncPluginEnv
comment:2 Changed 3 years ago by dgollub
- Status changed from new to assigned
Thanks, patch looks good, testsuite is running...
comment:3 Changed 3 years ago by dgollub
- Owner changed from dgollub to ianmartin
- Status changed from assigned to new
comment:4 in reply to: ↑ 1 Changed 3 years ago by dgollub
- Summary changed from [PATCH] [API] introduce reference counting for all modules/objects to [API] introduce reference counting for all modules/objects
comment:6 Changed 3 years ago by ianmartin
OSyncFormatEnv reference counting added in r4343
This patch introducs two new and removes one public interface(s): -osync_format_env_free +osync_format_env_unref +osync_format_env_ref
comment:7 Changed 3 years ago by chi70
- Summary changed from [API] introduce reference counting for all modules/objects to [API] [PATHC] introduce reference counting for all modules/objects
comment:8 Changed 3 years ago by chi70
- Summary changed from [API] [PATHC] introduce reference counting for all modules/objects to [API] [PATCH] introduce reference counting for all modules/objects
comment:9 Changed 3 years ago by felixmoeller
- Summary changed from [API] [PATCH] introduce reference counting for all modules/objects to [PATCH] [API] introduce reference counting for all modules/objects
my query just detects the patch in front. See http://opensync.org/report/12
comment:10 Changed 3 years ago by ianmartin
comment:11 Changed 3 years ago by ianmartin
OSyncModule committed in r4374
comment:12 Changed 3 years ago by dgollub
- Summary changed from [PATCH] [API] introduce reference counting for all modules/objects to [API] introduce reference counting for all modules/objects
All mentioned patches got committed - including the vformat.diff with r4347
comment:13 Changed 3 years ago by ianmartin
OSyncThread reference counting adding in r4375
comment:14 follow-up: ↓ 15 Changed 3 years ago by ianmartin
- Owner changed from ianmartin to dgollub
- Status changed from assigned to new
Left are:
# OSyncCapability # OSyncXMLFieldList # OSyncXMLField
OSyncCapability is essentially a linked list of OSyncCapability elements. So in the same way as OSyncList does it make sense to have reference counting?
The XMLField elements are used in a very non OO way in xmlformat so this is a more complicated task. Is this a change we want to make?
comment:15 in reply to: ↑ 14 ; follow-up: ↓ 16 Changed 3 years ago by dgollub
Replying to ianmartin:
Left are:
# OSyncCapability # OSyncXMLFieldList # OSyncXMLField
OSyncCapability is essentially a linked list of OSyncCapability elements. So in the same way as OSyncList does it make sense to have reference counting?
No.
The XMLField elements are used in a very non OO way in xmlformat so this is a more complicated task. Is this a change we want to make?
Not quite sure - internally we have still some _free() method for this. Introducing here ref-confing for OSyncXMLField as well would help to keep a clean API design. Since every "object" would have ref-counting.
Reg. OSyncCapability - i need to check if this get used at all. Maybe we can drop this - not quite sure - but is this used in the Public API at all in combination with other interfaces? e.g. OSyncPluginInfo? If not, what about dropping OSyncCapability entirely?
Reg. OSyncXMLFieldList - i need to check if there is any different to OSyncList. Maybe this got changed introduced to "wrap" GList...
comment:16 in reply to: ↑ 15 ; follow-up: ↓ 17 Changed 3 years ago by dgollub
Replying to dgollub:
Replying to ianmartin:
Left are:
# OSyncCapability # OSyncXMLFieldList # OSyncXMLField
OSyncCapability is essentially a linked list of OSyncCapability elements. So in the same way as OSyncList does it make sense to have reference counting?
No.
Just checked - OSyncCapability doesn't get used at all in the Public API. For "attaching" Capabilities to a plugin OSyncCapabilities get used instead. So i would vote for dropping OSyncCapability completely. Thoughts?
[...]
comment:17 in reply to: ↑ 16 Changed 3 years ago by ianmartin
Replying to dgollub:
Replying to dgollub:
Replying to ianmartin:
Left are:
# OSyncCapability # OSyncXMLFieldList # OSyncXMLField
OSyncCapability is essentially a linked list of OSyncCapability elements. So in the same way as OSyncList does it make sense to have reference counting?
No.
Just checked - OSyncCapability doesn't get used at all in the Public API. For "attaching" Capabilities to a plugin OSyncCapabilities get used instead. So i would vote for dropping OSyncCapability completely. Thoughts?
Dynamic capability generation in plugins requires the use of osync_capability_new so it cant be dropped.
comment:18 Changed 3 years ago by ianmartin
osync_field_free is internal to OSyncField. I dont think reference counting makes sense as a OSyncField only makes sense as part of an OSyncXMLFormat. It cannot be part of two OSyncXMLFormats and if you free the parent OSyncXMLFormat the field would be corrupted if you tried to use it. There can therefore only be one meaningful reference to the field from the parent format.
The only external 'free' function is osync_field_delete which removes the field from the OSyncXMLFormat and frees it.
comment:20 Changed 3 years ago by dgollub
- Status changed from new to closed
- Resolution set to fixed
So everything expect OSyncXMLField got reference counting. Thanks Ian!

Patch to add reference counting to osync_plugin_env