Skip to content
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

Add fcntl module #41

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Add fcntl module #41

wants to merge 1 commit into from

Conversation

krkacc
Copy link

@krkacc krkacc commented Jul 22, 2023

The socket module wouldn't compile when I tested cross compiling because it couldn't find sys/un.h, so I disabled AF_UNIX sockets on Windows.

Copy link
Collaborator

@klange klange left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While I see that you did set your email address in git since your previous submission, the author name on this commit is still "krkacc" which is not acceptable. Please set an appropriate author name and rewrite the commit.

Additionally, I would like to inquire about your use of Kuroko and your need for an fcntl module with F_GETFL/F_SETFL.

@@ -9,6 +9,7 @@
#ifdef _WIN32
#include <winsock2.h>
#include <ws2tcpip.h>
#undef AF_UNIX
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do not include unrelated changes in pull requests.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additionally, Windows has supported AF_UNIX for some time now, though I'm not sure where they're defining the relevant structs...

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

KRK_DOC(module, "@brief Provides access to file control functions.");

KRK_DOC(BIND_FUNC(module,fcntl),
"@brief Modify file fd with command cmd\n"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fcntl does a great many things and this is not a particularly good description of it.

"@brief Modify file fd with command cmd\n"
"@arguments fd,cmd,arg=0\n\n"
"@p cmd should be an integer value defined by the @c F options. "
"@p arg should be an integer value defined by the @ref mod_os @c O options.");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Many fcntl commands take a pointer to a struct of some form, and even those that take integers are mostly not the O_ file descriptor options.

Comment on lines +62 to +86
FCNTL_CONST(F_GETFL);
FCNTL_CONST(F_SETFL);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why just these two? Why not all the ones defined in POSIX?

#include <kuroko/value.h>
#include <kuroko/util.h>

#ifdef _WIN32
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should really be handled by excluding this module from the build targets on Windows in the Makefile.

return krk_runtimeError(KRK_EXC(typeError),
"expected integer or object with fileno(), not '%T'", fileno);
}
int result = fcntl(fd, cmd, arg);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While not likely to be relevant for the two exposed commands, fcntl can be interrupted for many commands, and going by what CPython does it would be worthwhile to catch EINTR and retry.

@krkacc
Copy link
Author

krkacc commented Jul 23, 2023

I have updated the author name and have rewritten the commit to address the feedback.

Additionally, I would like to inquire about your use of Kuroko and your need for an fcntl module with F_GETFL/F_SETFL.

I don't use Kuroko for much currently. I want to use fcntl for setting blocking/non-blocking mode on sockets.

@klange
Copy link
Collaborator

klange commented Jul 25, 2023

This is looking much better.

I don't want to add a new module at this stage in the 1.4 release schedule, and I don't have a separate development / release branching strategy at the moment, so I'll wait to merge until 1.4 is finished.

I will try to fix the Windows build of the socket module in 1.4, though.

@krkacc
Copy link
Author

krkacc commented Jul 25, 2023

Sounds good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants