首页 \ 问答 \ SSL + NIO的线程安全(Thread Safety with SSL + NIO)

SSL + NIO的线程安全(Thread Safety with SSL + NIO)

有一些有用的信息可用于使用Java实现SSLNIO (SocketChannel and SSLEngine) ,而不是使用netty等框架。

我试图提出一个SSL实现,可以使用blocking/non非阻塞通道,并获得一些基本的qns

当操作appData和Net缓冲区时,关于线程安全性要处理的问题没有太多信息。 根据SSLEngine的文档,

“有两个并发问题需要注意:

wrap()unwrap()方法可以彼此同时执行。

SSL/TLS协议使用有序数据包。 应用程序必须注意确保生成的数据包按顺序传递。 如果数据包无序到达,可能会发生意外或致命的结果。“

这适用于阻塞和非阻塞吗? 有人可以解释一下。 谢谢。

此外,设置初始缓冲区大小的一般建议似乎是基于( session.getApplicationBufferSize()/getPacketBufferSize() ),这些值将如何设置? 是否更好地使用这些标准缓冲区大小为32k左右?


There is some helpful information available on implementing the SSL with NIO (SocketChannel and SSLEngine) using java, not using a framework such as netty etc.

I am trying to come up with an SSL implementation that could work with blocking/non blocking channels and got some basic qns.

There is not much info on the issues to be dealt with thread safety, when the appData and Net buffers are being manipulated. Per the documentation of SSLEngine,

"There are two concurrency issues to be aware of:

The wrap() and unwrap() methods may execute concurrently of each other.

The SSL/TLS protocols employ ordered packets. Applications must take care to ensure that generated packets are delivered in sequence. If packets arrive out-of-order, unexpected or fatal results may occur."

Would this be applicable to both blocking and non blocking ? Could somebody explain. thanks.

Also, the general recommendation for setting up the initial buffer sizes seems to based of (session.getApplicationBufferSize()/getPacketBufferSize()), how would these values be set ? Are these better to be used instead of some standard buffer size of 32k or so ?


原文:https://stackoverflow.com/questions/39792626
更新时间:2023-05-21 17:05

最满意答案

如果要对“帐户”实例执行嵌套连接,则必须使用括号。

LEFT JOIN Account AccountA ON Opportunity.AccountId = AccountA.Id
LEFT JOIN (Account AccountB JOIN RecordType RecordTypeB ON AccountB.RecordTypeId = RecordTypeB.Id) 
    ON Opportunity.AccountId = AccountB.Id
LEFT JOIN (Account AccountC JOIN User UserB ON AccountC.OwnerId = UserB.Id) 
    ON Opportunity.AccountId = AccountC.Id
LEFT JOIN (Account AccountD JOIN User UserC ON AccountD.OwnerId = UserC.Id JOIN UserRole UserRoleA ON UserC.UserRoleId = UserRoleA.Id)
    ON Opportunity.AccountId = AccountD.Id

编辑:我修复了最后一行(带有AccountD的那一行)。


If you want to do nested joins to your "Account" instances, you have to use parentheses.

LEFT JOIN Account AccountA ON Opportunity.AccountId = AccountA.Id
LEFT JOIN (Account AccountB JOIN RecordType RecordTypeB ON AccountB.RecordTypeId = RecordTypeB.Id) 
    ON Opportunity.AccountId = AccountB.Id
LEFT JOIN (Account AccountC JOIN User UserB ON AccountC.OwnerId = UserB.Id) 
    ON Opportunity.AccountId = AccountC.Id
LEFT JOIN (Account AccountD JOIN User UserC ON AccountD.OwnerId = UserC.Id JOIN UserRole UserRoleA ON UserC.UserRoleId = UserRoleA.Id)
    ON Opportunity.AccountId = AccountD.Id

Edit: I fixed the last line (the one with AccountD).

相关问答

更多
  • 对于'急切加载'你使用.include ; .join用于执行INNER JOIN功能。 对于你的情况,你可能会同时使用这两种方式(加入获取照片,包含获得更多人)。 我明白这一点,因为.join本身不会执行急切的加载(所以在访问关联实体时会进行查询)。 如果您希望加载嵌套关联,则可以使用http://guides.rubyonrails.org/active_record_querying.html#eager-loading-multiple-associations上的Ruby on Rails指南中概 ...
  • (SELECT product.maker, laptop.model, laptop.price FROM Product INNER JOIN laptop ON product.model = laptop.model WHERE product.maker = "A" ) UNION (SELECT product.maker, pc.model, pc.price FROM Product INNER JOIN pc ON product.model = pc.model WHER ...
  • 弄清楚了。 这是查询: select from TableAObj where TableAOb.someCol = ? and TableAObj.TableBObj.TableCObj.someCol = ? 不需要重载的构造函数或显式连接。 Figured it out. Here's the query: select from TableAObj where TableAOb.someCol = ? and TableAObj.TableBObj.TableCObj.someCol = ? ...
  • 如果要对“帐户”实例执行嵌套连接,则必须使用括号。 LEFT JOIN Account AccountA ON Opportunity.AccountId = AccountA.Id LEFT JOIN (Account AccountB JOIN RecordType RecordTypeB ON AccountB.RecordTypeId = RecordTypeB.Id) ON Opportunity.AccountId = AccountB.Id LEFT JOIN (Account Ac ...
  • You need to set ON clause on every join table not only the lastone. 问候 JOIN `orders` ON ??? = ???, (SELECT SUM( orders.orderPrice ) FROM `orders` WHERE YEAR( orderDate ) = YEAR( CURDATE( ) ) ) AS year ON orders.sellerid = sellers.sellerid, ...
  • scope :incoming_requests, lambda{|mid| joins(:part => :product).where(:product => {:manufacturer_id => mid}) } scope :incoming_requests, lambda{|mid| joins(:part => :product).where(:product => {:manufacturer_id => mid}) }
  • 这是一个开始: SELECT * FROM Customer c INNER JOIN CustAppointments ca ON ca.CxId = c.CustomerID INNER JOIN ClinicRooms cr ON cr.AppRoomID = ca.AppRoomID INNER JOIN AppClinics ac ON ac.ClinID = cr.ClinID WHERE ap.ClinDate BETWEEN '20090101' AND '20 ...
  • 事实证明,你不能。 至少不是上面提供的语法,而不是CakePHP 1.2.6。 我检查了源代码(对开源框架!),并找到了包含连接代码的文件cake/libs/model/datasources/dbo_source.php 。 这一切都从DboSource::renderStatement()开始,它执行$query['joins']数组的浅步行过程,通过DboSource::buildJoinStatement($join)替换那些带有SQL片段的连接定义,它会完成一些整理参数(填充空白等),然后调用Db ...
  • 是的,你的怀疑是正确的 - 你放置sortBy / filter地方。 您可能需要将它们提取为单独的方法,并且可能需要将它们组合成方法,而不是使用filter / sortBy进行完整查询。 def partialReviewByPlaceIds(q: ReviewQuery, placeIds: Long*)(implicit psDAO: PlaceStatusDAO, upDAO: UserProfileDAO) = for { ((r, up), ps) <- Reviews join up ...
  • 您的ANSI-92 JOIN语法不正确 - 使用: CREATE VIEW Everything AS SELECT Suppliers.name as supplier, Parts.id, Parts.description, Types.typedesc as type FROM Suppliers JOIN Parts ON Suppliers.id = Parts.supplier_id JOIN Types ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。