Page MenuHomeFreeBSD

Factor out knote detach operations
ClosedPublic

Authored by markj on Jan 1 2017, 1:41 AM.
Tags
None
Referenced Files
Unknown Object (File)
Dec 25 2023, 1:10 AM
Unknown Object (File)
Nov 27 2023, 11:46 AM
Unknown Object (File)
Nov 24 2023, 2:55 PM
Unknown Object (File)
Nov 13 2023, 8:09 AM
Unknown Object (File)
Oct 24 2023, 9:50 AM
Unknown Object (File)
Oct 12 2023, 8:01 AM
Unknown Object (File)
Oct 6 2023, 8:28 AM
Unknown Object (File)
Sep 7 2023, 4:02 PM
Subscribers
None

Details

Summary

All but two knote_drop() calls are preceeded by:

if ((kn->kn_status & KN_DETACHED) != 0)
	kn->kn_fop->f_detach(kn);

One of them is the case where f_attach returns an error. In this case we
free the knote without detaching it, so the attach routine is not
allowed to return an error after adding the knote to a knlist.

The other case is knlist_cleardel(), which manually dequeues the knote
(and sets KN_DETACHED) by calling knlist_remove_kq() immediately before
calling knote_drop().

Therefore, move the detach operation into knote_drop().

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

markj retitled this revision from to Factor out knote detach operations.
markj edited the test plan for this revision. (Show Details)
markj updated this object.
kib edited edge metadata.

I like the change.

Myself, I would go even further, e.g. renaming knote_drop() to knote_drop_detached(), and using it in two places which you enumerated in the explanation. knote_drop() would assert KN_DETACHED and called f_detach() unconditionally.

This revision is now accepted and ready to land.Jan 1 2017, 10:17 AM
In D9015#186078, @kib wrote:

I like the change.

Myself, I would go even further, e.g. renaming knote_drop() to knote_drop_detached(), and using it in two places which you enumerated in the explanation. knote_drop() would assert KN_DETACHED and called f_detach() unconditionally.

Thanks, will do.

This revision was automatically updated to reflect the committed changes.