SeattleTestbed / attic

ARCHIVAL: Full mirror of SeattleTestbed's SVN in early 2014. We use GitHub since!
MIT License
0 stars 1 forks source link

dylink's import-only-once strategy precludes certain function overrides #1408

Open choksi81 opened 10 years ago

choksi81 commented 10 years ago

dylink imports libraries only once (see #1318, #1320). Further calls to dylink requesting to import the same library will refer back to the instance that is already imported.

This makes overriding functions in certain libraries impossible. Consider Affix, where we want to override network calls. All libraries that Affix itself imports (or its libraries imports!) cannot be modified later on. Illustrative code snippets:

cachedadvertise.r2py:

dy_import_module_symbols("sockettimeout.repy")

-------

affix_wrapper_lib.repy:

# We require cachedadvertise for some functionality...
dy_import_module_symbols("cachedadvertise.r2py")

# ...and will do our own thing before we link in sockettimeout
override_network_calls_with_custom_functions()
dy_import_module_symbols("sockettimeout.repy")

sockettimeout should use the overridden functions, but that's not the case. This seems to be the root cause of #1407, seash's NAT traversal broken, and is similar to #1366, openconnection not overwritten.

What should we do about this? From my tests, dylinkbehaves as Python does; also, a few libraries must only be imported once (see #1319 for an issue with uniqueid). OTOH, the functionality to re-import / flush / import under a different name would be very useful, think Affix and Security Layers. Let me hear your opinions on this.