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 a way to set context mode when creating context #134

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

craff
Copy link
Contributor

@craff craff commented Jun 2, 2023

create_context has distinct default mode for blocking and Runtime_lock.

Also add tests for Runtime_lock

…t mode for blocking and Runtime_lock.

Also test Runtime_lock
@craff
Copy link
Contributor Author

craff commented Jun 2, 2023

This addresses issue #122

@craff
Copy link
Contributor Author

craff commented Jun 2, 2023

@anmonteiro This PR coould be extended with a set_mode function ?

src/ssl.ml Outdated
let (lor) = (lor)
end

(** Allow SSL_write(..., n) to return r with 0 < r < n (i.e. report success
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this comment misplaced? What's doing this exactly?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeh, a wrong paste: fixed

src/ssl.ml Outdated
module Modes = struct
type t = int

let no_mode = 0x000
Copy link
Collaborator

Choose a reason for hiding this comment

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

could you add a link to where these values are defined?

src/ssl.ml Outdated
@@ -77,6 +77,26 @@ type verify_error =
| Error_v_keyusage_no_certsign
| Error_v_application_verification

module Modes = struct
Copy link
Collaborator

Choose a reason for hiding this comment

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

alternative design:

  • use a variant with all the modes
  • accept a list of modes
  • OR the modes in the list to get mode

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Pro of the list design

  • often use in OCAml
  • allows for pattern matching
    Cons
  • slow
  • allocates
  • many more lines of codes.

Moreover, if OCaml allowed pattern matching on "constant", i.e. value known at compile time, pattern matching would still be possible.

Copy link
Collaborator

Choose a reason for hiding this comment

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

we can probably make it non-allocating if it's just pattern matches to convert to int, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Collaborator

@anmonteiro anmonteiro left a comment

Choose a reason for hiding this comment

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

can you move the tests to a separate PR?

I don't know if this is what you asked in the other PR but I'd prefer:

  • 1 PR for modes handling
  • 1 PR with tests for Runtime_lock

@craff
Copy link
Contributor Author

craff commented Jun 5, 2023

can you move the tests to a separate PR?

I don't know if this is what you asked in the other PR but I'd prefer:

* 1 PR for `modes` handling

* 1 PR with tests for `Runtime_lock`

done

@craff
Copy link
Contributor Author

craff commented Jun 5, 2023 via email

@craff
Copy link
Contributor Author

craff commented Jun 5, 2023

I have investigate async mode more. It seems that openssl can do async computation even when the user does not require async_job manually, if async mode is enabled (the doc is not really clear).

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