Пример #1
0
JNIEXPORT jint JNICALL
Java_OnloadTemplateSend_Update ( JNIEnv* env, jclass cls,
                                 jobject handle, jobject data,
                                 jint offset, jint flags )
{
	jlong h = GetLongFromObject( env, handle, "handle" );
	struct onload_template_msg_update_iovec update;
	jint rval = 0;
	jint fd = GetIntFromObject( env, handle, "fd" );
	if ( (*env)->ExceptionOccurred(env) )
		return -EINVAL;

	update.otmu_base = (*env)->GetDirectBufferAddress( env, data );
	if ( !update.otmu_base )
		return -ENOMEM;
	update.otmu_len = (*env)->GetDirectBufferCapacity( env, data );
	if ( update.otmu_len < 1 )
		return -ENOMEM;

	update.otmu_offset = offset;
	update.otmu_flags = 0;

	rval = onload_msg_template_update( fd,
	                                   (onload_template_handle) h,
	                                   &update, 1, flags );
	if ( rval >= 0 && (flags & ONLOAD_TEMPLATE_FLAGS_SEND_NOW) ) {
		SetLongOnObject( env, handle, "opaque", -1 );
	}
	return rval;
}
Пример #2
0
int templated_send(int handle, struct iovec* iov)
{
  onload_template_handle tmpl;
  struct onload_template_msg_update_iovec update;

  struct iovec initial;
  initial.iov_base = iov->iov_base;
  initial.iov_len = iov->iov_len;

  update.otmu_base = iov->iov_base;
  update.otmu_len = iov->iov_len;
  update.otmu_offset = 0;
  update.otmu_flags = 0;

  /* Note: This is initialising, and then updating to the same values.
   * A real application would update only a subset of the values, and
   * usually with different values.
   */
  TRY( onload_msg_template_alloc(handle, &initial, 1, &tmpl, 0));
  return onload_msg_template_update(handle, tmpl, &update, 1,
                                    ONLOAD_TEMPLATE_FLAGS_SEND_NOW);
}