-
Notifications
You must be signed in to change notification settings - Fork 396
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added a per thread buffer and related tests for OMR socket API #4555
Conversation
@rwy0717 @babsingh First, I need to include Also, when we run |
You will have to include a path, and use
When you start implementing for Unix, you will need to include stubs for Windows. Windows won't pick up from You can disable the test on Windows by updating the makefile; exclude the Refer to the code and make files in |
@babsingh Is it possible to move contents of When I include the path to
I think it may be because the compiler is confused between |
You are likely to cause redefinition errors as before if you expose struct definitions to the OMR consumer via You are getting the compile error because It needs to be
Let me know if this works. |
Hi Babneet, sorry for the late reply. That method definitely works after I added a struct for However, I'm having trouble picturing how that will work for the users because I think the users will need to declare and allocate space for structures like In |
@caohaley Can you elaborate on your issue with a simple use-case/example? |
@babsingh Basically, I'm still a bit confused on how the users will use our program. For example, in
I think the users may need to access the structs to allocate them locally, even though they won't need to access the elements inside. |
@babsingh However, I was talking to @rwy0717 and Robert brought up that in (Allocation in Therefore, we can maybe follow what |
@rwy0717 is correct. Similarly, you can hide allocations for other structs in create/open/init methods, and de-allocate them during close/free/destroy methods. |
I see, we could do that. But how would we keep track of what was allocated? For example, in |
A user can do three things before invoking the omrsock API:
Your API should handle all three scenarios. If your API does not handle all three scenarios, then you should clearly state the usage of your API in the description with examples.
You can use |
I see that makes a lot of sense, thank you Babneet! I will look into it more. |
@babsingh Would it be helpful if we made the definition of the OMRSocket struct:
When we allocate the OMRSocket struct for the user, we set curMemoryIndex to 0, and initialize all elements of memoryManagement to NULL. When we need to allocate memory we copy the pointer to the block of memory we allocate, to the memoryManagement array and increment curMemoryIndex. If the user has already allocated memory for a struct, we simply just don't allocate the memory and don't add it to the memoryManagement array. At the very end, we free the pointers to the memory one by one. |
@caohaley What do you want to store for every |
I was thinking we could store the pointers to all the structs that we allocate for the user. I used a maximum of 30 allocations per socket_t that for the user, as an example. Or we could use the hash table and it would look more clean. However, it may require more lines of programming. |
@babsingh For the static and dynamic allocation method, will we still have the user include both
|
You can just do the allocation for them in your API, and mention usage of the API with examples in the description. Then, users won't have to worry about allocations and including header files.
You need to identify all the structs per socket. Create a struct like:
Allocate/initialize meta at the start, and de-allocate meta at the end. If there are global structures (shared by the entire socket library), then store them in |
70ce9e4
to
2ab2866
Compare
Mirrored all function prototypes to win32/omrsock.c and unix/omrsock.c - OMRSOCK API will have a Unix and Windows implementation. - win32/omrsock.c and unix/omrsock do not have function descriptions. Refer to common/omrsock.c for the function descriptions. Issue: eclipse-omr#4102 co-authored-by: Babneet Singh <sbabneet@ca.ibm.com> Signed-off-by: Haley Cao <haleycao88@hotmail.com>
Added new error codes in omrporterror.h for OMRSOCK API uses - Added error codes to omrporterror.h to have specific errors corresponding to the omrsockptb function failures and system full error. Issue: eclipse-omr#4102 co-authored-by: Babneet Singh <sbabneet@ca.ibm.com> Signed-off-by: Haley Cao <haleycao88@hotmail.com>
Startup|shutdown OMRSOCK API with per thread buffer starup|shutdown - Added implementations for startup and shutdown for OMRSOCK API for Unix and win32, that simply calls the corresponding omrsockptb helper functions. - Startup will call omrsock_ptb_init to initialize the omrsock per thread buffer key, while shutdown will call omrsock_ptb_shutdown to free any allocated data and destroy the key. Issue: eclipse-omr#4102 co-authored-by: Babneet Singh <sbabneet@ca.ibm.com> Signed-off-by: Haley Cao <haleycao88@hotmail.com>
Added OMRSOCK API functions declarations in PortLibrary startup and shutdown - Declare function prototypes in PortLibrary. - Startup and shutdown of the API will be called during startup and shutdown of PortLibrary. Issue: eclipse-omr#4102 co-authored-by: Babneet Singh <sbabneet@ca.ibm.com> Signed-off-by: Haley Cao <haleycao88@hotmail.com>
Added Unix implementation which uses OMRSOCK API per thread buffer - Used old j9sock API template to implement omrsock_getaddrinfo_create_hints which uses omrsockptb helper function omrsock_ptb_get. - The implementation checks and allocates memory for users to make a hints structure, which is later passed into omrsock_getaddrinfo. Issue: eclipse-omr#4102 co-authored-by: Babneet Singh <sbabneet@ca.ibm.com> Signed-off-by: Haley Cao <haleycao88@hotmail.com>
Added to tests per_thread_buffer_functionality and library_function_pointers_not_null - Modified build for omrsockTest.cpp so that only Unix systems run the tests. - Test that all OMRSOCK API functions exists. - Test omrsock PTB indirectly by using sock_getaddrinfo_create_hints to set up hints and then check if it exists. Issue: eclipse-omr#4102 co-authored-by: Babneet Singh <sbabneet@ca.ibm.com> Signed-off-by: Haley Cao <haleycao88@hotmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm.
@genie-omr build all |
Fixed the name of the argument to match similar functions - Changed name from hints to handle for the omrsock_addrinfo_t pointer. Issue: eclipse-omr#4745 Depends on PR: eclipse-omr#4555 Signed-off-by: Haley Cao <haleycao88@hotmail.com>
To extract length, family, socktype, protocol from addrInfo of OMRAddrInfoNode struct - The OMRAddrInfoNode has two elements, which first element, named addrInfo, is a pointer to the first addrinfo node in a linked list of addrinfo nodes. - The Unix addrinfo structs contains many elements which stores a variety of information about a socket address. - Extracts unix addrinfo elements by passing in a pointer to a OMRAddrInfoNode and the index of which one of the linked list of addrinfo nodes to extract. - Currently implemented the element extractions of what is needed to create a socket. Issue: eclipse-omr#4745 Depends on PR:eclipse-omr#4555 Signed-off-by: Haley Cao <haleycao88@hotmail.com>
Added test implementations for per_thread_buffer_functionality test - Added implementations to first create a hints structure, which relies on the per thread buffer structure and functions. - Added values to hints, which is stored by per thread buffer and the element getters retrieves the values and compare them to values inserted. Issue: eclipse-omr#4745 Depends on PR:eclipse-omr#4555 Signed-off-by: Haley Cao <haleycao88@hotmail.com>
@rwy0717 The checks has passed. |
Fixed the name of the argument to match similar functions - Changed name from hints to handle for the omrsock_addrinfo_t pointer. Issue: eclipse-omr#4745 Depends on PR: eclipse-omr#4555 Signed-off-by: Haley Cao <haleycao88@hotmail.com>
To extract length, family, socktype, protocol from addrInfo of OMRAddrInfoNode struct - The OMRAddrInfoNode has two elements, which first element, named addrInfo, is a pointer to the first addrinfo node in a linked list of addrinfo nodes. - The Unix addrinfo structs contains many elements which stores a variety of information about a socket address. - Extracts unix addrinfo elements by passing in a pointer to a OMRAddrInfoNode and the index of which one of the linked list of addrinfo nodes to extract. - Currently implemented the element extractions of what is needed to create a socket. Issue: eclipse-omr#4745 Depends on PR:eclipse-omr#4555 Signed-off-by: Haley Cao <haleycao88@hotmail.com>
Added test implementations for per_thread_buffer_functionality test - Added implementations to first create a hints structure, which relies on the per thread buffer structure and functions. - Added values to hints, which is stored by per thread buffer and the element getters retrieves the values and compare them to values inserted. Issue: eclipse-omr#4745 Depends on PR:eclipse-omr#4555 Signed-off-by: Haley Cao <haleycao88@hotmail.com>
To extract length, family, socktype, protocol from addrInfo of OMRAddrInfoNode struct - The OMRAddrInfoNode has two elements, which first element, named addrInfo, is a pointer to the first addrinfo node in a linked list of addrinfo nodes. - The Unix addrinfo structs contains many elements which stores a variety of information about a socket address. - Extracts unix addrinfo elements by passing in a pointer to a OMRAddrInfoNode and the index of which one of the linked list of addrinfo nodes to extract. - Currently implemented the element extractions of what is needed to create a socket. Issue: eclipse-omr#4745 Depends on PR:eclipse-omr#4555 Signed-off-by: Haley Cao <haleycao88@hotmail.com>
Added test implementations for per_thread_buffer_functionality test - Added implementations to first create a hints structure, which relies on the per thread buffer structure and functions. - Added values to hints, which is stored by per thread buffer and the element getters retrieves the values and compare them to values inserted. Issue: eclipse-omr#4745 Depends on PR:eclipse-omr#4555 Signed-off-by: Haley Cao <haleycao88@hotmail.com>
Added test implementations for per_thread_buffer_functionality test - Added implementations to first create a hints structure, which relies on the per thread buffer structure and functions. - Added values to hints, which is stored by per thread buffer and the element getters retrieves the values and compare them to values inserted. Issue: eclipse-omr#4745 Depends on PR:eclipse-omr#4555 Signed-off-by: Haley Cao <haleycao88@hotmail.com>
Added test implementations for per_thread_buffer_functionality test - Added implementations to first create a hints structure, which relies on the per thread buffer structure and functions. - Added values to hints, which is stored by per thread buffer and the element getters retrieves the values and compare them to values inserted. Issue: eclipse-omr#4745 Depends on PR:eclipse-omr#4555 Signed-off-by: Haley Cao <haleycao88@hotmail.com>
Created 4 commits for this PR:
Added Omrsock Related Per Thread Buffer functions
contains changes related to the per thread buffer and its functionalities.Added startup and shutdown functions to omrsock API
contains changes related to OMR socket API startup and shutdown, which utilizes the ptb functions in the previous commit to startup and shutdown the per thread buffer.Added Unix implementation for omrsock_getaddrinfo_create_hints
contains implementation of the OMR socket API function, that uses the ptb function to store information. It also contains a few new error codes related to OMR socket API.Added Implementations to omrsockTest.cpp to test omrsock PTB
contains tests that are still being work on for the per thread buffer.