core.c (f94f3cb37a1c4d44dd2070cc4a6165689bda9c92) | core.c (fada4ac33992b1f953d95584e36f6ca7860aea40) |
---|---|
1/* 2 CMTP implementation for Linux Bluetooth stack (BlueZ). 3 Copyright (C) 2002-2003 Marcel Holtmann <marcel@holtmann.org> 4 5 This program is free software; you can redistribute it and/or modify 6 it under the terms of the GNU General Public License version 2 as 7 published by the Free Software Foundation; 8 --- 21 unchanged lines hidden (view full) --- 30#include <linux/poll.h> 31#include <linux/fcntl.h> 32#include <linux/freezer.h> 33#include <linux/skbuff.h> 34#include <linux/socket.h> 35#include <linux/ioctl.h> 36#include <linux/file.h> 37#include <linux/init.h> | 1/* 2 CMTP implementation for Linux Bluetooth stack (BlueZ). 3 Copyright (C) 2002-2003 Marcel Holtmann <marcel@holtmann.org> 4 5 This program is free software; you can redistribute it and/or modify 6 it under the terms of the GNU General Public License version 2 as 7 published by the Free Software Foundation; 8 --- 21 unchanged lines hidden (view full) --- 30#include <linux/poll.h> 31#include <linux/fcntl.h> 32#include <linux/freezer.h> 33#include <linux/skbuff.h> 34#include <linux/socket.h> 35#include <linux/ioctl.h> 36#include <linux/file.h> 37#include <linux/init.h> |
38#include <linux/kthread.h> |
|
38#include <net/sock.h> 39 40#include <linux/isdn/capilli.h> 41 42#include <net/bluetooth/bluetooth.h> 43#include <net/bluetooth/l2cap.h> 44 45#include "cmtp.h" --- 184 unchanged lines hidden (view full) --- 230 if (tail < 5) { 231 cmtp_send_frame(session, nskb->data, nskb->len); 232 skb_trim(nskb, 0); 233 tail = session->mtu; 234 } 235 236 size = min_t(uint, ((tail < 258) ? (tail - 2) : (tail - 3)), skb->len); 237 | 39#include <net/sock.h> 40 41#include <linux/isdn/capilli.h> 42 43#include <net/bluetooth/bluetooth.h> 44#include <net/bluetooth/l2cap.h> 45 46#include "cmtp.h" --- 184 unchanged lines hidden (view full) --- 231 if (tail < 5) { 232 cmtp_send_frame(session, nskb->data, nskb->len); 233 skb_trim(nskb, 0); 234 tail = session->mtu; 235 } 236 237 size = min_t(uint, ((tail < 258) ? (tail - 2) : (tail - 3)), skb->len); 238 |
238 if ((scb->id < 0) && ((scb->id = cmtp_alloc_block_id(session)) < 0)) { 239 skb_queue_head(&session->transmit, skb); 240 break; | 239 if (scb->id < 0) { 240 scb->id = cmtp_alloc_block_id(session); 241 if (scb->id < 0) { 242 skb_queue_head(&session->transmit, skb); 243 break; 244 } |
241 } 242 243 if (size < 256) { 244 hdr = skb_put(nskb, 2); 245 hdr[0] = 0x40 246 | ((scb->id << 2) & 0x3c) 247 | ((skb->len == size) ? 0x00 : 0x01); 248 hdr[1] = size; --- 30 unchanged lines hidden (view full) --- 279{ 280 struct cmtp_session *session = arg; 281 struct sock *sk = session->sock->sk; 282 struct sk_buff *skb; 283 wait_queue_t wait; 284 285 BT_DBG("session %p", session); 286 | 245 } 246 247 if (size < 256) { 248 hdr = skb_put(nskb, 2); 249 hdr[0] = 0x40 250 | ((scb->id << 2) & 0x3c) 251 | ((skb->len == size) ? 0x00 : 0x01); 252 hdr[1] = size; --- 30 unchanged lines hidden (view full) --- 283{ 284 struct cmtp_session *session = arg; 285 struct sock *sk = session->sock->sk; 286 struct sk_buff *skb; 287 wait_queue_t wait; 288 289 BT_DBG("session %p", session); 290 |
287 daemonize("kcmtpd_ctr_%d", session->num); | |
288 set_user_nice(current, -15); 289 290 init_waitqueue_entry(&wait, current); 291 add_wait_queue(sk_sleep(sk), &wait); | 291 set_user_nice(current, -15); 292 293 init_waitqueue_entry(&wait, current); 294 add_wait_queue(sk_sleep(sk), &wait); |
292 while (!atomic_read(&session->terminate)) { | 295 while (!kthread_should_stop()) { |
293 set_current_state(TASK_INTERRUPTIBLE); 294 295 if (sk->sk_state != BT_CONNECTED) 296 break; 297 298 while ((skb = skb_dequeue(&sk->sk_receive_queue))) { 299 skb_orphan(skb); 300 cmtp_recv_frame(session, skb); --- 61 unchanged lines hidden (view full) --- 362 363 for (i = 0; i < 16; i++) 364 session->reassembly[i] = NULL; 365 366 session->flags = req->flags; 367 368 __cmtp_link_session(session); 369 | 296 set_current_state(TASK_INTERRUPTIBLE); 297 298 if (sk->sk_state != BT_CONNECTED) 299 break; 300 301 while ((skb = skb_dequeue(&sk->sk_receive_queue))) { 302 skb_orphan(skb); 303 cmtp_recv_frame(session, skb); --- 61 unchanged lines hidden (view full) --- 365 366 for (i = 0; i < 16; i++) 367 session->reassembly[i] = NULL; 368 369 session->flags = req->flags; 370 371 __cmtp_link_session(session); 372 |
370 err = kernel_thread(cmtp_session, session, CLONE_KERNEL); 371 if (err < 0) | 373 session->task = kthread_run(cmtp_session, session, "kcmtpd_ctr_%d", 374 session->num); 375 if (IS_ERR(session->task)) { 376 err = PTR_ERR(session->task); |
372 goto unlink; | 377 goto unlink; |
378 } |
|
373 374 if (!(session->flags & (1 << CMTP_LOOPBACK))) { 375 err = cmtp_attach_device(session); 376 if (err < 0) 377 goto detach; 378 } 379 380 up_write(&cmtp_session_sem); --- 20 unchanged lines hidden (view full) --- 401 402 down_read(&cmtp_session_sem); 403 404 session = __cmtp_get_session(&req->bdaddr); 405 if (session) { 406 /* Flush the transmit queue */ 407 skb_queue_purge(&session->transmit); 408 | 379 380 if (!(session->flags & (1 << CMTP_LOOPBACK))) { 381 err = cmtp_attach_device(session); 382 if (err < 0) 383 goto detach; 384 } 385 386 up_write(&cmtp_session_sem); --- 20 unchanged lines hidden (view full) --- 407 408 down_read(&cmtp_session_sem); 409 410 session = __cmtp_get_session(&req->bdaddr); 411 if (session) { 412 /* Flush the transmit queue */ 413 skb_queue_purge(&session->transmit); 414 |
409 /* Kill session thread */ 410 atomic_inc(&session->terminate); 411 cmtp_schedule(session); | 415 /* Stop session thread */ 416 kthread_stop(session->task); |
412 } else 413 err = -ENOENT; 414 415 up_read(&cmtp_session_sem); 416 return err; 417} 418 419int cmtp_get_connlist(struct cmtp_connlist_req *req) --- 72 unchanged lines hidden --- | 417 } else 418 err = -ENOENT; 419 420 up_read(&cmtp_session_sem); 421 return err; 422} 423 424int cmtp_get_connlist(struct cmtp_connlist_req *req) --- 72 unchanged lines hidden --- |