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)
Nov 5 2024, 7:29 AM
Unknown Object (File)
Sep 27 2024, 1:07 PM
Unknown Object (File)
Sep 25 2024, 4:47 PM
Unknown Object (File)
Sep 22 2024, 7:51 PM
Unknown Object (File)
Sep 22 2024, 9:12 AM
Unknown Object (File)
Sep 18 2024, 2:56 PM
Unknown Object (File)
Sep 17 2024, 10:54 PM
Unknown Object (File)
Sep 11 2024, 8:33 AM
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.