1 /* 2 Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 3 4 This program is free software; you can redistribute it and/or modify 5 it under the terms of the GNU General Public License, version 2.0, 6 as published by the Free Software Foundation. 7 8 This program is also distributed with certain software (including 9 but not limited to OpenSSL) that is licensed under separate terms, 10 as designated in a particular file or component or in included license 11 documentation. The authors of MySQL hereby grant you an additional 12 permission to link the program and your derivative works with the 13 separately licensed software that they have included with MySQL. 14 15 This program is distributed in the hope that it will be useful, 16 but WITHOUT ANY WARRANTY; without even the implied warranty of 17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 GNU General Public License, version 2.0, for more details. 19 20 You should have received a copy of the GNU General Public License 21 along with this program; if not, write to the Free Software 22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 23 */ 24 25 #ifndef SQL_CHANNEL_INFO_INCLUDED 26 #define SQL_CHANNEL_INFO_INCLUDED 27 28 #include "my_global.h" // uint 29 #include "my_sys.h" // my_micro_time 30 31 class THD; 32 typedef struct st_vio Vio; 33 34 35 /** 36 This abstract base class represents connection channel information 37 about a new connection. Its subclasses encapsulate differences 38 between different connection channel types. 39 40 Currently we support local and TCP/IP sockets (all platforms), 41 named pipes and shared memory (Windows only). 42 */ 43 class Channel_info 44 { 45 ulonglong prior_thr_create_utime; 46 47 protected: 48 /** 49 Create and initialize a Vio object. 50 51 @retval return a pointer to the initialized a vio object. 52 */ 53 virtual Vio* create_and_init_vio() const = 0; 54 Channel_info()55 Channel_info() 56 : prior_thr_create_utime(0) 57 { } 58 59 public: ~Channel_info()60 virtual ~Channel_info() {} 61 62 /** 63 Instantiate and initialize THD object and vio. 64 65 @return 66 @retval 67 THD* pointer to initialized THD object. 68 @retval 69 NULL THD object allocation fails. 70 */ 71 virtual THD* create_thd() = 0; 72 73 /** 74 Send error back to the client and close the channel. 75 76 @param errorcode code indicating type of error. 77 @param error operating system specific error code. 78 @param senderror true if the error need to be sent to 79 client else false. 80 */ 81 virtual void send_error_and_close_channel(uint errorcode, 82 int error, 83 bool senderror) = 0; 84 get_prior_thr_create_utime()85 ulonglong get_prior_thr_create_utime() const 86 { return prior_thr_create_utime; } 87 set_prior_thr_create_utime()88 void set_prior_thr_create_utime() 89 { prior_thr_create_utime= my_micro_time(); } 90 }; 91 92 #endif // SQL_CHANNEL_INFO_INCLUDED. 93